6 #define ASSERT(x) assert(x)
\r
12 #define COUNTOF(arr) (sizeof(arr)/sizeof((arr)[0]))
\r
15 #define __ORTE_DLL_NAME "orted.dll"
\r
17 #define __ORTE_DLL_NAME "orte.dll"
\r
20 struct __ORTE_DLL __orte;
\r
22 static const LPCSTR orteFnNames[] = {
\r
25 "ORTEDomainPropDefaultGet",
\r
26 "ORTEDomainInitEvents",
\r
27 "ORTEDomainAppCreate",
\r
28 "ORTEDomainAppDestroy",
\r
29 "ORTEDomainAppSubscriptionPatternAdd",
\r
30 "ORTEDomainAppSubscriptionPatternRemove",
\r
31 "ORTEDomainAppSubscriptionPatternDestroy",
\r
32 "ORTEDomainMgrCreate",
\r
33 "ORTEDomainMgrDestroy",
\r
34 "ORTEPublicationCreate",
\r
35 "ORTEPublicationDestroy",
\r
36 "ORTEPublicationPropertiesGet",
\r
37 "ORTEPublicationPropertiesSet",
\r
38 "ORTEPublicationWaitForSubscriptions",
\r
39 "ORTEPublicationGetStatus",
\r
40 "ORTEPublicationSend",
\r
41 "ORTEPublicationSendEx",
\r
42 "ORTESubscriptionCreate",
\r
43 "ORTESubscriptionDestroy",
\r
44 "ORTESubscriptionPropertiesGet",
\r
45 "ORTESubscriptionPropertiesSet",
\r
46 "ORTESubscriptionWaitForPublications",
\r
47 "ORTESubscriptionGetStatus",
\r
48 "ORTESubscriptionPull",
\r
49 "ORTETypeRegisterAdd",
\r
50 "ORTETypeRegisterDestroyAll",
\r
51 "ORTEVerbositySetOptions",
\r
52 "ORTEVerbositySetLogFile",
\r
54 "IPAddressToString",
\r
55 "StringToIPAddress",
\r
56 "NtpTimeToStringMs",
\r
63 FARPROC *functionTable,
\r
64 const LPCSTR *names,
\r
68 FARPROC *pfnMax = functionTable + count;
\r
70 while (functionTable < pfnMax) {
\r
71 *functionTable = GetProcAddress(hInst, *names);
\r
72 if (!*functionTable)
\r
73 return GetLastError();
\r
78 return ERROR_SUCCESS;
\r
82 #define ORTE_GET_PROC_ADDRESS(symbol) __orte.apis.symbol = (PFN_ ## symbol)GetProcAddress(__orte.hInstance, # symbol)
\r
85 SomePointerNull(FARPROC *functionTable, unsigned count)
\r
87 FARPROC *max = functionTable + count;
\r
89 while (functionTable < max) {
\r
90 if (*functionTable == NULL)
\r
100 __ORTEDllLoad(void)
\r
102 if (!__orte.cLoads && !__orte.fLoadTried) {
\r
103 __orte.fLoadTried = 1;
\r
105 __orte.hInstance = LoadLibrary(__ORTE_DLL_NAME);
\r
107 if (__orte.hInstance) {
\r
109 ASSERT(sizeof(struct __ORTE_APIS) / sizeof(FARPROC) == COUNTOF(orteFnNames));
\r
111 __orte.dwResult = GetProcAddresses(
\r
113 (FARPROC *)&__orte.apis,
\r
115 COUNTOF(orteFnNames));
\r
117 if (__orte.dwResult != ERROR_SUCCESS) {
\r
118 FreeLibrary(__orte.hInstance);
\r
119 __orte.hInstance = NULL;
\r
121 __orte.dwResult = ERROR_SUCCESS;
\r
124 __orte.dwResult = GetLastError();
\r
128 if (__orte.dwResult == ERROR_SUCCESS)
\r
129 InterlockedIncrement(&__orte.cLoads);
\r
131 return __orte.dwResult;
\r
137 DWORD res = __ORTEDllLoad();
\r
139 if (res == ERROR_SUCCESS)
\r
140 __orte.apis.pfnORTEInit();
\r