#ifndef RBAPP_H #define RBAPP_H /* ** Copyright (c) Digital Equipment Corporation, 1996 ** All Rights Reserved. Unpublished rights reserved ** under the copyright laws of the United States. ** ** The software contained on this media is proprietary ** to and embodies the confidential technology of ** Digital Equipment Corporation. Possession, use, ** duplication or dissemination of the software and ** media is authorized only pursuant to a valid written ** license from Digital Equipment Corporation. ** ** RESTRICTED RIGHTS LEGEND Use, duplication, or ** disclosure by the U.S. Government is subject to ** restrictions as set forth in Subparagraph (c)(1)(ii) ** of DFARS 252.227-7013, or in FAR 52.227-19, as ** applicable. ** ** NAME: ** ** rbappdef.h ** ** FACILITY: ** ** Resource Broker ** ** ABSTRACT: ** ** Resource Broker Common API helper definitions for ODL ** expansion. ** ** This include file contains definitions for all the symbols and macros ** necessary for compiling the output of the 'mktyplib' compiler. If ** these symbols have been defined externally, the following #ifndef ** should skip the rest of the file, so as to not multiply-define ** things. ** */ #include /* The following #ifdef skips all the remaining definitions if we already */ /* have definitions from some other source than objbase.h. We picked IID_IUnknown */ /* just because it's a commonly used symbol and should be unambiguous indication */ /* that the definitions have been made. */ #ifndef IID_IUnknown /* the following #ifdef handles platform independence of some macros */ /* that are defined in WIN32-specific include files. As COM and OLE */ /* become pervasive, maybe we can get rid of most of these. */ /* The definitions of RB_OK, RB_FAIL, and RB_FALSE are to avoid conflicts */ /* with DCE defined symbols. As of DCE V2.0, we can get rid of these and */ /* just use S_OK, S_FAIL, and S_FALSE. The STDCALL decorator gets expanded */ /* differently on WIN32 platforms from everything else. */ #ifdef _WIN32 #include #include #define RB_OK S_OK #define RB_FAIL S_FAIL #define RB_FALSE S_FALSE #define STDCALL _stdcall #else /* non-WIN32 */ /* some standard WIN32 types used in expansion */ typedef void* LPVOID; typedef unsigned long ULONG; #ifndef NODECLAREHRESULT /* Allows explicit suppression of HRESULT definition */ /* For getting HRESULT defined. The definition is conditional because the dce/nbase.h file for DCE 1.1 also contains definitions for HRESULT, S_OK, and S_FALSE. */ #if (!defined(S_OK) || !defined(S_FALSE)) /* ** As we must define HRESULT, make sure we define it compatibly ** with the declaration in nbase.h (idl_long_int -- 32-bit integer). */ #if defined(VAX) || defined(__VAX) /* For VAX 32-bit int */ typedef long int RB_HRESULT; #else /* For Digital UNIX + VMS/Alpha 32-bit int */ typedef int RB_HRESULT; #endif #define HRESULT RB_HRESULT #endif #endif #ifndef S_OK static const int S_OK =0x00000000; #endif #ifndef S_FALSE static const int S_FALSE =0x00000001; #endif /* HRESULT value definitions for non-Windows platforms. These are copied */ /* verbatim from the Windows "objbase.h" file. */ static const int RB_OK =0x00000000; static const int RB_FALSE =0x00000001; static const int E_UNEXPECTED =0x8000FFFF; static const int E_NOTIMPL =0x80000001; static const int E_OUTOFMEMORY =0x80000002; static const int E_INVALIDARG =0x80000003; static const int E_NOINTERFACE =0x80000004; static const int E_POINTER =0x80000005; static const int E_HANDLE =0x80000006; static const int E_FAIL =0x80000008; static const int E_ACCESSDENIED =0x80000009; /* still more decorations to satisfy WIN32 and not screw */ /* up other platforms. */ #define CDECL #define FAR #define STDCALL /* handles "C" definitions when C++ compiler in charge */ #ifdef __cplusplus #define EXTERN_C extern "C" #else #define EXTERN_C extern #endif /* These expand the macros generated by the ODL compiler to put the right return */ /* types and decorators on method definitions. In general, macros that end in an */ /* underscore are used for methods that return a value. Consider the following */ /* ODL definition: */ /* interface Foo { */ /* void Bar(); */ /* int Baz([in] int Xyzzy); */ /* } */ /* The ODL compiler expands it as follows: */ /* DECLARE_INTERFACE(Foo) */ /* { */ /* STDMETHOD_(void, Bar)(THIS) PURE; */ /* STDMETHOD_(int, Baz)(THIS_ int Xyzzy) PURE; */ /* }; */ /* See below for examples of how these are expanded for C and C++; */ #define STDMETHODCALLTYPE #define STDAPICALLTYPE #define STDAPI EXTERN_C HRESULT STDAPICALLTYPE #define STDAPI_(type) EXTERN_C type STDAPICALLTYPE #define STDMETHODIMP HRESULT STDMETHODCALLTYPE #define STDMETHODIMP_(type) type STDMETHODCALLTYPE /* The following macros expand differently under C and C++ compilation, to provide */ /* the correct definitions of the VTBL for the two languages. It is intended that */ /* the two expansions compile into bit-for-bit compatible structures. */ /* Here is the WIN32 C++ expansion of the above example: */ /* class Foo */ /* { */ /* virtual void Bar(void) = 0; */ /* virtual int Baz(int Xyzzy) = 0; */ /* } */ /* /* typedef struct Foo { */ /* const struct FooVtbl* lpVtbl; */ /* } Foo; */ /* typedef const struct FooVtbl FooVtbl; */ /* const struct FooVtbl */ /* { */ /* void (_stdcall* Foo)(void); */ /* int (_stdcall* Bar)(int Xyzzy); */ /* }; */ #if defined(__cplusplus) #define interface struct #define STDMETHOD(method) virtual HRESULT STDMETHODCALLTYPE method #define STDMETHOD_(type,method) virtual type STDMETHODCALLTYPE method #define PURE = 0 #define THIS_ #define THIS void #define DECLARE_INTERFACE(iface) interface iface #define DECLARE_INTERFACE_(iface, baseiface) interface iface : public baseiface #else /*__clusplus */ #define interface struct #define STDMETHOD(method) HRESULT (STDMETHODCALLTYPE * method) #define STDMETHOD_(type,method) type (STDMETHODCALLTYPE * method) #define PURE #define THIS_ INTERFACE FAR* This, #define THIS INTERFACE FAR* This #ifdef CONST_VTABLE #define CONST_VTBL const #define DECLARE_INTERFACE(iface) \ typedef interface iface { \ const struct iface##Vtbl FAR* lpVtbl; \ } iface; \ typedef const struct iface##Vtbl iface##Vtbl; \ const struct iface##Vtbl #else /*CONST_VTABLE */ #define CONST_VTBL #define DECLARE_INTERFACE(iface) \ typedef interface iface { \ struct iface##Vtbl FAR* lpVtbl; \ } iface; \ typedef struct iface##Vtbl iface##Vtbl; \ struct iface##Vtbl #endif /*CONST_VTABLE */ #define DECLARE_INTERFACE_(iface, baseiface) DECLARE_INTERFACE(iface) #endif /*__clusplus */ /*GUID structure for DEFINE_GUID macro */ typedef struct _GUID { unsigned int Data1; unsigned short Data2; unsigned short Data3; unsigned char Data4[8]; } GUID; typedef GUID IID; typedef GUID CLSID; /*references to GUID's are different in C and C++ */ #if defined(__cplusplus) #define REFGUID const GUID & #define REFIID const IID & #define REFCLSID const CLSID & #else /*__cplusplus */ #define REFGUID const GUID * const #define REFIID const IID * const #define REFCLSID const CLSID * const #endif /*__cplusplus */ /*operations on GUIDs, redefined for C and C++ */ #ifdef __cplusplus inline int IsEqualGUID(REFGUID rguid1, REFGUID rguid2) { return !memcmp(&rguid1, &rguid2, sizeof(GUID)); } #else /*! __cplusplus */ #define IsEqualGUID(rguid1, rguid2) (!memcmp(rguid1, rguid2, sizeof(GUID))) #endif /*__cplusplus */ #define IsEqualIID(riid1, riid2) IsEqualGUID(riid1, riid2) #define IsEqualCLSID(rclsid1, rclsid2) IsEqualGUID(rclsid1, rclsid2) #ifdef __cplusplus inline int operator==(const GUID& guidOne, const GUID& guidOther) { return !memcmp(&guidOne,&guidOther,sizeof(GUID)); } inline int operator!=(const GUID& guidOne, const GUID& guidOther) { return !(guidOne == guidOther); } #endif /*__cplusplus */ /* Canonical definition of IUnknown and associates, expanded appropriately */ /* for C++ and C compilations. */ #ifdef __cplusplus extern "C" { #endif #ifdef __cplusplus interface IUnknown { public: virtual HRESULT STDCALL QueryInterface( /* [in] */ REFIID riid, /* [out] */ void FAR * FAR *ppvObject) = 0; virtual ULONG STDCALL AddRef( void) = 0; virtual ULONG STDCALL Release( void) = 0; }; #else /*__cplusplus */ interface IUnknown; typedef struct IUnknownVtbl { HRESULT ( STDCALL FAR *QueryInterface )( interface IUnknown FAR * This, /* [in] */ REFIID riid, /* [out] */ void FAR *FAR *ppvObject); ULONG ( STDCALL FAR *AddRef )( interface IUnknown FAR * This); ULONG ( STDCALL FAR *Release )( interface IUnknown FAR * This); } IUnknownVtbl; interface IUnknown { CONST_VTBL struct IUnknownVtbl FAR *lpVtbl; }; #endif /*__cplusplus */ #ifdef __cplusplus } #endif /*__cplusplus */ #endif /* non-WIN32 */ /* The following definition is used to provide import/export function in */ /* the Windows NT environment. If the API_EXPORT or BUILDING_DLL symbols */ /* are defined, then the following global symbols are exported from the */ /* DLL. Otherwise, they are imported from the DLL. */ #ifndef _WIN32 #define API_IMPORT_EXPORT #elif defined(API_EXPORT) || defined(BUILDING_DLL) #define API_IMPORT_EXPORT _declspec(dllexport) #else #define API_IMPORT_EXPORT _declspec(dllimport) #endif /* GUIDs get declared and instantiated by the *same* macro, depending on */ /* the preprocessor variable INITGUID. So long as it is undefined, the */ /* DEFINE_GUID macro ignores its final 11 arguments and just compiles */ /* a const external reference to the GUID. If INITGUID is defined, then */ /* the INITGUID macro expands to a const external variable with an */ /* appropriate initializer list. The DEFINE_GUID macro is re-defined to /* get the API_IMPORT_EXPORT declaration decorator into the expanded symbol. */ #undef DEFINE_GUID #ifdef _WIN32 #ifndef INITGUID #define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \ EXTERN_C API_IMPORT_EXPORT const GUID CDECL FAR name #else #define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \ EXTERN_C const GUID API_IMPORT_EXPORT CDECL name \ = { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } } #endif /*INITGUID */ #else /* not _WIN32 */ /* need reference to IID_IUnknown */ #define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \ static const GUID API_IMPORT_EXPORT CDECL name \ = { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } } DEFINE_GUID(IID_IUnknown, 0x00000000u, 0x0000, 0x0000, 0xC0, 0x00, 0x0, 0x0, 0x0, 0x0, 0x0, 0x46); #endif /* The following #include brings in all the definitions generated by the */ /* ODL compiler. */ #include /* The following routine retrieves an object representing the broker itself */ EXTERN_C API_IMPORT_EXPORT RBBrokerPtr STDCALL RBGetBroker(); /* The following routines convert safely to/from RBObjects */ EXTERN_C API_IMPORT_EXPORT RBObjectPtr STDCALL RBToRBObject(RBUnknownPtr Object); EXTERN_C API_IMPORT_EXPORT RBBrokerPtr STDCALL RBToRBBroker(RBObjectPtr Object); EXTERN_C API_IMPORT_EXPORT RBResourcePtr STDCALL RBToRBResource(RBObjectPtr Object); EXTERN_C API_IMPORT_EXPORT RBServicePtr STDCALL RBToRBService(RBObjectPtr Object); EXTERN_C API_IMPORT_EXPORT RBServerPtr STDCALL RBToRBServer(RBObjectPtr Object); EXTERN_C API_IMPORT_EXPORT RBAttrPtr STDCALL RBToRBAttr(RBObjectPtr Object); #endif /* IID_IUnknown */ #endif /* RBAPP_H */