#include <assert.h>\r
\r
#ifdef _DEBUG\r
- #define ASSERT(x) assert(x)\r
+ #define ASSERT(x) assert(x)\r
#else\r
#define ASSERT(x)\r
#endif\r
\r
\r
-#define COUNTOF(arr) (sizeof(arr)/sizeof((arr)[0]))\r
+#define COUNTOF(arr) (sizeof(arr)/sizeof((arr)[0]))\r
\r
#ifdef _DEBUG\r
- #define __ORTE_DLL_NAME "orted.dll"\r
+ #define __ORTE_DLL_NAME "orted.dll"\r
#else\r
- #define __ORTE_DLL_NAME "orte.dll"\r
+ #define __ORTE_DLL_NAME "orte.dll"\r
#endif\r
\r
struct __ORTE_DLL __orte;\r
\r
static const LPCSTR orteFnNames[] = {\r
- "ORTEInit",\r
- "ORTEDomainStart",\r
- "ORTEDomainPropDefaultGet",\r
- "ORTEDomainInitEvents",\r
- "ORTEDomainAppCreate",\r
- "ORTEDomainAppDestroy",\r
- "ORTEDomainAppSubscriptionPatternAdd",\r
- "ORTEDomainAppSubscriptionPatternRemove",\r
- "ORTEDomainAppSubscriptionPatternDestroy",\r
- "ORTEDomainMgrCreate",\r
- "ORTEDomainMgrDestroy",\r
- "ORTEPublicationCreate",\r
- "ORTEPublicationDestroy",\r
- "ORTEPublicationPropertiesGet",\r
- "ORTEPublicationPropertiesSet",\r
- "ORTEPublicationWaitForSubscriptions",\r
- "ORTEPublicationGetStatus",\r
- "ORTEPublicationSend",\r
- "ORTEPublicationSendEx",\r
- "ORTESubscriptionCreate",\r
- "ORTESubscriptionDestroy",\r
- "ORTESubscriptionPropertiesGet",\r
- "ORTESubscriptionPropertiesSet",\r
- "ORTESubscriptionWaitForPublications",\r
- "ORTESubscriptionGetStatus",\r
- "ORTESubscriptionPull",\r
- "ORTETypeRegisterAdd",\r
- "ORTETypeRegisterDestroyAll",\r
- "ORTEVerbositySetOptions",\r
- "ORTEVerbositySetLogFile",\r
- "ORTESleepMs",\r
- "IPAddressToString",\r
- "StringToIPAddress",\r
- "NtpTimeToStringMs",\r
- "NtpTimeToStringUs"\r
+ "ORTEInit",\r
+ "ORTEDomainStart",\r
+ "ORTEDomainPropDefaultGet",\r
+ "ORTEDomainInitEvents",\r
+ "ORTEDomainAppCreate",\r
+ "ORTEDomainAppDestroy",\r
+ "ORTEDomainAppSubscriptionPatternAdd",\r
+ "ORTEDomainAppSubscriptionPatternRemove",\r
+ "ORTEDomainAppSubscriptionPatternDestroy",\r
+ "ORTEDomainMgrCreate",\r
+ "ORTEDomainMgrDestroy",\r
+ "ORTEPublicationCreate",\r
+ "ORTEPublicationDestroy",\r
+ "ORTEPublicationPropertiesGet",\r
+ "ORTEPublicationPropertiesSet",\r
+ "ORTEPublicationWaitForSubscriptions",\r
+ "ORTEPublicationGetStatus",\r
+ "ORTEPublicationSend",\r
+ "ORTEPublicationSendEx",\r
+ "ORTESubscriptionCreate",\r
+ "ORTESubscriptionDestroy",\r
+ "ORTESubscriptionPropertiesGet",\r
+ "ORTESubscriptionPropertiesSet",\r
+ "ORTESubscriptionWaitForPublications",\r
+ "ORTESubscriptionGetStatus",\r
+ "ORTESubscriptionPull",\r
+ "ORTETypeRegisterAdd",\r
+ "ORTETypeRegisterDestroyAll",\r
+ "ORTEVerbositySetOptions",\r
+ "ORTEVerbositySetLogFile",\r
+ "ORTESleepMs",\r
+ "IPAddressToString",\r
+ "StringToIPAddress",\r
+ "NtpTimeToStringMs",\r
+ "NtpTimeToStringUs"\r
};\r
\r
-DWORD GetProcAddresses(\r
- HINSTANCE hInst,\r
- FARPROC *functionTable,\r
- const LPCSTR *names,\r
- unsigned count\r
-)\r
+DWORD\r
+GetProcAddresses(\r
+ HINSTANCE hInst,\r
+ FARPROC *functionTable,\r
+ const LPCSTR *names,\r
+ unsigned count\r
+ )\r
{\r
- FARPROC *pfnMax = functionTable + count;\r
+ FARPROC *pfnMax = functionTable + count;\r
\r
- while (functionTable < pfnMax) {\r
- *functionTable = GetProcAddress(hInst, *names);\r
- if (!*functionTable)\r
- return GetLastError();\r
- ++functionTable;\r
- ++names;\r
- }\r
+ while (functionTable < pfnMax) {\r
+ *functionTable = GetProcAddress(hInst, *names);\r
+ if (!*functionTable)\r
+ return GetLastError();\r
+ ++functionTable;\r
+ ++names;\r
+ }\r
\r
- return ERROR_SUCCESS;\r
+ return ERROR_SUCCESS;\r
}\r
\r
#if 0\r
-#define ORTE_GET_PROC_ADDRESS(symbol) __orte.apis.symbol = (PFN_##symbol)GetProcAddress(__orte.hInstance, #symbol)\r
+#define ORTE_GET_PROC_ADDRESS(symbol) __orte.apis.symbol = (PFN_ ## symbol)GetProcAddress(__orte.hInstance, # symbol)\r
\r
-int SomePointerNull(FARPROC *functionTable, unsigned count)\r
+int\r
+SomePointerNull(FARPROC *functionTable, unsigned count)\r
{\r
- FARPROC *max = functionTable + count;\r
+ FARPROC *max = functionTable + count;\r
\r
- while (functionTable < max) {\r
- if (*functionTable == NULL)\r
- return 1;\r
- ++functionTable;\r
- }\r
+ while (functionTable < max) {\r
+ if (*functionTable == NULL)\r
+ return 1;\r
+ ++functionTable;\r
+ }\r
\r
- return 0;\r
+ return 0;\r
}\r
#endif\r
\r
-DWORD __ORTEDllLoad(void)\r
+DWORD\r
+__ORTEDllLoad(void)\r
{\r
- if (!__orte.cLoads && !__orte.fLoadTried) {\r
- __orte.fLoadTried = 1;\r
- \r
- __orte.hInstance = LoadLibrary(__ORTE_DLL_NAME);\r
- \r
- if (__orte.hInstance) {\r
- \r
- ASSERT(sizeof(struct __ORTE_APIS) / sizeof(FARPROC) == COUNTOF(orteFnNames));\r
-\r
- __orte.dwResult = GetProcAddresses(\r
- __orte.hInstance,\r
- (FARPROC*)&__orte.apis,\r
- orteFnNames,\r
- COUNTOF(orteFnNames));\r
- \r
- if (__orte.dwResult != ERROR_SUCCESS) {\r
- FreeLibrary(__orte.hInstance);\r
- __orte.hInstance = NULL;\r
- } else {\r
- __orte.dwResult = ERROR_SUCCESS;\r
- }\r
- } else {\r
- __orte.dwResult = GetLastError();\r
- }\r
- }\r
-\r
- if (__orte.dwResult == ERROR_SUCCESS)\r
- InterlockedIncrement(&__orte.cLoads);\r
-\r
- return __orte.dwResult;\r
+ if (!__orte.cLoads && !__orte.fLoadTried) {\r
+ __orte.fLoadTried = 1;\r
+\r
+ __orte.hInstance = LoadLibrary(__ORTE_DLL_NAME);\r
+\r
+ if (__orte.hInstance) {\r
+\r
+ ASSERT(sizeof(struct __ORTE_APIS) / sizeof(FARPROC) == COUNTOF(orteFnNames));\r
+\r
+ __orte.dwResult = GetProcAddresses(\r
+ __orte.hInstance,\r
+ (FARPROC *)&__orte.apis,\r
+ orteFnNames,\r
+ COUNTOF(orteFnNames));\r
+\r
+ if (__orte.dwResult != ERROR_SUCCESS) {\r
+ FreeLibrary(__orte.hInstance);\r
+ __orte.hInstance = NULL;\r
+ } else {\r
+ __orte.dwResult = ERROR_SUCCESS;\r
+ }\r
+ } else {\r
+ __orte.dwResult = GetLastError();\r
+ }\r
+ }\r
+\r
+ if (__orte.dwResult == ERROR_SUCCESS)\r
+ InterlockedIncrement(&__orte.cLoads);\r
+\r
+ return __orte.dwResult;\r
}\r
\r
-DWORD __ORTEInit(void)\r
+DWORD\r
+__ORTEInit(void)\r
{\r
- DWORD res = __ORTEDllLoad();\r
+ DWORD res = __ORTEDllLoad();\r
\r
- if (res == ERROR_SUCCESS)\r
- __orte.apis.pfnORTEInit();\r
+ if (res == ERROR_SUCCESS)\r
+ __orte.apis.pfnORTEInit();\r
\r
- return res;\r
+ return res;\r
}\r