#if !defined(AFX_ABCCOMMON_H__4645BD46_A1E3_11D3_9D28_0000F80788FD__INCLUDED_) #define AFX_ABCCOMMON_H__4645BD46_A1E3_11D3_9D28_0000F80788FD__INCLUDED_ // Emulate new C++ language features on some legacy platforms // You also need a library built with a compatible compiler #if defined(__DECCXX_VER) && !defined(_BOOL_EXISTS) // before Compaq C++ 6.0 #define HAS_NO_BOOL 1 #define HAS_NO_NAMESPACE 1 #elif defined(_MSC_VER) && (_MSC_VER < 1100) // before VC 5.0 #define HAS_NO_BOOL 1 #define HAS_NO_NAMESPACE 1 #elif defined(__GNUC__) && (__GNUC__ < 3) && (__GNUC_MINOR__ < 8) // before GCC 2.8 and 3.0 #define HAS_NO_BOOL 1 #define HAS_NO_NAMESPACE 1 #elif defined(__SUNPRO_CC) && !defined(_BOOL) // before 5.0 #define HAS_NO_BOOL 1 #define HAS_NO_NAMESPACE 1 #endif // assume other compilers support ANSI C++ bool and namespace #ifdef HAS_NO_BOOL #define bool char #define true (1==1) #define false (1==0) #endif #include #include "rtrapi.h" #include #include #ifdef HAS_NO_NAMESPACE #include // cout #else #include // cout using namespace std; // need cxx /stan=strict_ansi or -std strict_ansi #endif #ifdef _WIN32 #define WIN32_LEAN_AND_MEAN #include // gethostname() #else #include // gethostname() #if defined(__SunOS_5_5) || defined(__SunOS_5_5_1) extern "C" { extern int gethostname( char *name, int namelen); // missing from unistd.h } #endif #endif const unsigned int ABCMAX_HOSTNAME_LEN = 256; // MAXHOSTNAMELEN const unsigned int ABCMAX_STRING_LEN = 100; const rtr_const_facnam_t ABCFacility = "ABCFacility"; const rtr_const_parnam_t ABCPartition1 = "ABCPartition1"; const rtr_const_parnam_t ABCPartition2 = "ABCPartition2"; const unsigned int ABC_BOOK = 1; const unsigned int ABC_MAGAZINE = 2; typedef rtr_status_t abc_status; const int ABCSuccess = RTR_STS_OK; const signed int ABC_STS_BASE = RTR_STS_APPSTATUSBASE; const signed int ABCOrderSucceeded = ABC_STS_BASE; const signed int ABCOrderFailed = ABC_STS_BASE-RTR_NEXTVALIDAPPSTATUS; inline void print_status_on_failure(rtr_status_t sStatus) { switch (sStatus) { case ABCSuccess : case ABCOrderSucceeded : case ABCOrderFailed : break; default: cout << RTR::GetErrorText(sStatus) << endl; break; } return; } inline rtr_status_t StartRTR() { // // If RTR is not already started then start it now. // rtr_status_t sStatus = RTR_STS_OK; RTR RTROnThisNode; if (false == RTROnThisNode.IsRunning()) { sStatus = RTROnThisNode.Start(); print_status_on_failure(sStatus); } // // Since this is a sample we can create the journal with supersede // RTROnThisNode.CreateJournal(true); // supersede return sStatus; } inline rtr_status_t CreateFacility() { // // Create a Facility // rtr_status_t sStatus; RTRFacilityManager FacilityManager; // Get the local node name char nodename[ABCMAX_HOSTNAME_LEN+1]; nodename[ABCMAX_HOSTNAME_LEN]= '\0'; // ensure terminated gethostname(&nodename[0],ABCMAX_HOSTNAME_LEN); // Create the facility specifying that the local node has all roles // and bEnableRouterCallout but not bEnableBackendCallout sStatus = FacilityManager.CreateFacility(ABCFacility,nodename,nodename,nodename,false,false); print_status_on_failure(sStatus); return sStatus; } #endif