Validates a specific context handle (hCtx).
Syntax
ESS_FUNC_M EssValidateHCtx (hCtx);
Parameter | Data Type | Description |
---|---|---|
hCtx | ESS_HCTX_T | The API context handle to validate |
Notes
This function can be used after any extended wait period to ensure the program's context handle is still recognized by the server.
Return Value
This function returns 0 if the context handle is valid, otherwise it returns an error code to indicate the invalid context handle. Possible reasons for an invalid context handle include the login might have timed out or the user was explicitly logged out by the supervisor.
Access
This function requires no special access.
Example
#include <essapi.h> char sApplication[] = "accept"; char sDbName[] = "basic"; char sFilename[] = "basic"; char SvrName[] = "local"; char User[] = "test"; char Password[] = "testing"; ESS_HINST_T hInst; ESS_HCTX_T hCtx; FILE *fpOutfile; void ESS_Init() { ESS_STS_T sts; ESS_INIT_T InitStruct = { ESS_API_VERSION, /* This should be set to ESS_API_VERSION */ NULL, /* void pointer to user's message context */ 0L, /* max number of context handles required */ 255, /* max size of buffer that can be allocated*/ NULL, /* local path to use for file operations */ NULL, /* full path name of message database file */ NULL, /* user-defined memory allocation function */ NULL, /* user-defined memory reallocation function*/ NULL, /* user-defined memory free function */ NULL, /* user-defined message callback function */ NULL, /* user-defined help file path */ 0L /* reserved for internal use */ }; if ((sts = EssInit(&InitStruct, &hInst)) != ESS_STS_NOERR) { fprintf(stdout, "EssInit failure: %ld\n", sts); exit ((int) sts); } fprintf(stdout, "EssInit sts: %ld\n", sts); } void ESS_Login () { ESS_STS_T sts = ESS_STS_NOERR; ESS_USHORT_T Items; ESS_PAPPDB_T pAppsDbs = NULL; sts = EssLogin (hInst, SvrName, User, Password, &Items, &pAppsDbs, &hCtx); printf("EssLogin sts: %ld\r\n", sts); } void ESS_Term() { ESS_STS_T sts = ESS_STS_NOERR; if ((sts = EssTerm(hInst)) != ESS_STS_NOERR) { /* error terminating API */ exit((ESS_USHORT_T) sts); } fprintf(stdout, "EssTerm sts: %ld\r\n", sts); } void ESS_Logout() { ESS_STS_T sts = ESS_STS_NOERR; sts = EssLogout (hCtx); fprintf(stdout, "\n\nEssLogout sts: %ld\n",sts); } void ESS_SetActive() { ESS_STS_T sts = ESS_STS_NOERR; ESS_ACCESS_T Access; ESS_STR_T AppName; ESS_STR_T DbName; AppName = sApplication; DbName = sDbName; sts = EssSetActive(hCtx, AppName, DbName, &Access); fprintf(stdout, "EssSetActive sts: %ld\r\n",sts); } /*****************************************************/ /*************** MAIN FUNCTION ***********************/ void main(int argc, char ** argv) { ESS_STS_T sts; ESS_Init(); ESS_Login(); ESS_SetActive(); /* Do something else, not related to Essbase*/ sts = EssValidateHCtx (hCtx); if (sts) { ESS_Login() ; ESS_SetActive(); } /* Do the actual processing now */ EssClearActive(hCtx); ESS_Logout(); ESS_Term(); }
See Also