Passed to the API initialization function EssInit() and contains fields that let API developers customize their usage of the API. If any of the fields of the structure are set to zero (or NULL for pointers), the API defaults are used. (See Using Memory in C Programs for more information.).
typedef struct ESS_INIT_T { ESS_ULONG_T Version; ESS_PVOID_T UserContext; ESS_USHORT_T MaxHandles; ESS_SIZE_T MaxBuffer; ESS_STR_T LocalPath; ESS_STR_T MessageFile; ESS_PFUNC_T AllocFunc; ESS_PFUNC_T ReallocFunc; ESS_PFUNC_T FreeFunc; ESS_PFUNC_T MessageFunc; ESS_STR_T HelpFile; ESS_ULONG_T Ess_System; #ifdef AD_UTF8 ESS_USHORT_T, usApiType; #endif ESS_PCATCHFUNC_T, CatchFunc; ESS_PCATCH_INIT_FUNC_T, CatchInitFunc; ESS_PCATCH_TERM_FUNC_T, CatchTermFunc; ESS_PCOOKIE_CREATE_FUNC_T, CookieCreateFunc; ESS_PCOOKIE_DELETE_FUNC_T, CookieDeleteFunc; } ESS_INIT_T, *ESS_PINIT_T;
Data Type | Field | Description |
---|---|---|
ESS_ULONG_T | Version | Version of Essbase API used to compile the application. Should be set to ESS_API_VERSION. Used for backward compatibility. |
ESS_PVOID_T | UserContext | An optional pointer to a user-defined message context (passed as argument to a user-defined MessageFunction) |
ESS_USHORT_T | MaxHandles | The maximum number of simultaneous context handles required by the API program (between 1 and 255). The default is 255. Reducing this number may decrease the amount of client memory used within the API for your program. |
ESS_SIZE_T | MaxBuffer | The maximum size buffer that can be allocated in the client program (typically 64 KB). The default is 64 KB. |
ESS_STR_T | LocalPath | The default local path name to use for file and object operations on the client. If this is not set, Essbase uses the ESSBASEPATH environment variable by default, and appends \CLIENT to the directory name passed in. . |
ESS_STR_T | MessageFile | Qualified path name of the message database file, ESSBASE.MDB. If this is not set, Essbase first tries to use the fully qualified path in the ARBORMSGPATH environment variable, otherwise, it uses (ESSBASEPATH)\BIN\ESSBASE.MDB. If ESSBASEPATH is not defined, an error is returned at run time. |
ESS_PFUNC_T | AllocFunc | Pointer to the user-defined memory allocation function. All platforms: memory allocation functions use the malloc() function. |
ESS_PFUNC_T | ReallocFunc | Pointer to the user-defined memory reallocation function. All platforms: memory allocation functions use the realloc() function. |
ESS_PFUNC_T | FreeFunc | A pointer to the user-defined memory free function. All platforms: memory allocation functions use the free() function. |
ESS_PFUNC_T | MessageFunc | A pointer to the user-defined message callback function. Messages sent to the user-defined Callback function are passed to Essbase in EssInit. Previous to Release 6.2, if a message contained NLS characters (foreign language characters, such as accented characters), Essbase provided them in OEM (DOS) format. In Release 6.2 and later, these messages are completely in character (Windows) format, to avoid the misinterpretation of certain characters. This only affects localized versions of Essbase. |
ESS_STR_T | HelpFile | Fully-qualified path name of the user-defined application help file, used for help for the AutoLogin dialog box. The login help context must be defined in the help file. See Integrating Essbase With Your Product. By default, clicking the Help button displays the Essbase System Login help topic shipped with the Oracle Essbase Spreadsheet Add-in User's Guide online help. If ESSBASEPATH is not defined, the help file name is set to null. |
ESS_ULONG_T | Ess_System | Reserved for internal use. Set to NULL |
ESS_USHORT_T | usApiType | Required. Defines whether the program is in Unicode or non-Unicode mode. For valid values, see Unicode Mode Constants (C). |
typedef ESS_BOOL_T (*ESS_PCATCHFUNC_T)(ESS_HCTX_T); | CatchFunc | If implemented by the client, Essbase calls this function intermittently (every few seconds) during queries. If the routine retuns TRUE, the API call gets canceled. |
typedef ESS_STS_T (*ESS_PCATCH_INIT_FUNC_T)(ESS_ HCTX _T); | CatchInitFunc | This function initializes resources for whatever state is needed for the CatchFunc call. For example, if you want to terminate a query based on whether a user hits the ESC key, and CatchFunc calls on a routine to get data from the keyboard, you may need to pre-initialize memory so that it is not initialized for every CatchFunc call. Essbase executes the following process during a query:
|
typedef ESS_STS_T (*ESS_PCATCH_TERM_FUNC_T)(ESS_ HCTX _T); | CatchTermFunc | This function terminates resources initialized by CatchInitFunc. |
typedef ESS_STS_T (*ESS_PCOOKIE_CREATE_FUNC_T)(ESS_HCTX_T); | CookieCreateFunc | Essbase calls this function at SetActive time. You would use this function if user information is required for the CatchFunc, CatchInitFunc, or CatchTermFunc calls. For example, if you want to terminate a query based on certain user activities, you may need to create a cookie to be used by the CatchFunc call. You obtain the cookie by calling EssGetCookie. |
typedef ESS_STS_T (*ESS_PCOOKIE_DELETE_FUNC_T)(ESS_HCTX_T); | CookieDeleteFunc | This function deletes the cookie created by CookieCreateFunc. Essbase calls this function at ClearActive time. |
Query Cancellation Using Essbase API
Programs developed using the Essbase API can optionally register custom query-cancellation functions at initialization. ESS_INIT_T has five fields that enable development of custom callback functions for query cancellation. These fields are CatchFunc, CatchInitFunc, CatchTermFunc, CookieCreateFunc, and CookieDeleteFunc. By default, they are set to null.
Query Cancellation Usage Example
The following code enables query cancellation when the Escape key is hit. KbdHitEx gets the next key that was entered from the keyboard, and writes the value of the key to kbfinfo.chChar.
ESS_INIT_STRUCT InitStruct; InitStruct.CatchFunc = KillReqCatcher; ESS_BOOL_T KillReqCatcher(ESS_HCTX_T hCtx) { KBDINFO_T kbinfo; if (KbdHitEx(&kbfinfo) && kbfinfo.chChar == KB_ESC) return ESS_TRUE; else return ESS_FALSE; }
However, suppose the routine KdbHitEx requires that an initialization routine InitializeMyKeyboard be called first, and a terminate TerminateMyKeyboard routine be called later. Here you would use CatchInitFunc and CatchTermFunc.
InitStruct.CatchInitFunc = InitKeyboard; InitStruct.CatchTermFunc = TerminateKeyboard; ESS_STS_T InitKeyboard (ESS_HCTX_T hCtx) { return InitializeMyKeyboard (); } ESS_STS_T TerminateKeyboard (ESS_HCTX_T hCtx) { return TerminateMyKeyboard (); }
Now suppose that the InitializeMyKeyboard and TerminateMyKeyboard routines need to retain status information. You can use a cookie to retain the status. The cookie created by CookieCreateFunc can be accessed in CatchFunc, CatchInitFunc, and CatchTermFunc by EssGetCookie.
InitStruct.CatchInitFunc = InitKeyboard2; InitStruct.CatchTermFunc = TerminateKeyboard2; InitStruct.CookieCreateFunc = AllocKeyboardState; InitStruct.CookieDeleteFunc = FreeKeyboardState; ESS_STS_T InitKeyboard2 (ESS_HCTX_T hCtx) { ESS_PVOID_T cookie; ESS_STS_T sts; sts = EssGetCookie(hCtx, &cookie); if (sts) return sts; return InitializeMyKeyboard (cookie); } ESS_STS_T TerminateKeyboard2 (ESS_HCTX_T hCtx) { ESS_PVOID_T cookie; ESS_STS_T sts; sts = EssGetCookie(hCtx, &cookie); if (sts) return sts; return TerminateMyKeyboard (cookie); } ESS_STS_T AllocKeyboardState(ESS_PVOID_T pKbdState) { *pKbdState = malloc(KBDSTRUCT_SIZE); if (*pKbdState) return 0; else return -1; } ESS_STS_T FreeKeyboardState (ESS_PVOID_T kbdState) { if (kbdState) free(kbdState); return 0; }