C/C++ API
HSM Dinamo
Loading...
Looking for...
No entries found
download_log.c

Example of downloading logs.

See Note on examples.
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <dinamo.h> /* header do Dinamo */
#define HOST_ADDR "127.0.0.1"
#define USER_ID "master"
#define USER_PWD "12345678"
int main()
{
int nRet = 0;
struct AUTH_PWD authPwd;
HSESSIONCTX hSession = 0;
DWORD dwLogServerSize = 0;
DWORD dwLogSize = 0;
BYTE *cbLog = 0;
/* initializes the Dinamo library */
nRet = DInitialize (0);
if ( nRet!=0 ) {
printf ( "Failed to initialize Dinamo library. Code %d\n", nRet );
goto clean;
}
printf ("Library initialized.\n");
/* initializes the structure for connecting to Dinamo */
strncpy(authPwd. szAddr, HOST_ADDR, sizeof(authPwd.szAddr));
authPwd. nPort = DEFAULT_PORT;
strncpy(authPwd. szUserId, USER_ID, sizeof(authPwd.szUserId));
strncpy(authPwd. szPassword, USER_PWD, sizeof(authPwd.szPassword));
/* opens an encrypted session while bypassing load balancing */
nRet = DOpenSession ( &hSession, SS_USER_PWD,(BYTE *)&authPwd, sizeof(authPwd), CLEAR_CONN|LB_BYPASS );
if ( nRet!=0 ) {
printf ("Error opening session with Dinamo. Code %d\n", nRet);
goto clean;
}
printf ( "Session open.\n" );
/* ******************************************************* */
/* here begins the treatment to receive the server log */
/* ******************************************************* */
/* get size of LOG on server */
nRet = DGetStatLogSize ( hSession, &dwLogServerSize );
if ( nRet == 0 ) {
printf ("Size of LOG on server without formatting: "DWORD_PRINT" byte(s).\n", dwLogServerSize);
}
if ( dwLogServerSize>0 ) {
cbLog =(BYTE *)DAlloc ( dwLogServerSize ); /* allocates memory */
if ( cbLog ) {
/* receives all the contents of the log. */
nRet = DGetStatLog (hSession, GET_LOG_START_FULL, GET_LOG_END_FULL, &dwLogSize, &cbLog );
DFree ( cbLog ); /* frees memory */
}
}
clean:
/* closing the session */
if ( hSession )
{
DCloseSession ( &hSession, 0 );
printf ( "Session closed.\n" );
}
/* closes the Dinamo library */
return nRet;
}
HSM Application Programming Interface (API) Dinamo.
void * HSESSIONCTX
Definition dinamo.h:68
#define DEFAULT_PORT
Definition dinamo.h:1948
#define DWORD_PRINT
Definition dinamo.h:55
#define CLEAR_CONN
Definition dinamo.h:587
unsigned char BYTE
Definition dinamo.h:45
#define GET_LOG_START_FULL
Definition dinamo.h:1522
#define LB_BYPASS
Definition dinamo.h:588
unsigned int DWORD
Definition dinamo.h:46
#define SS_USER_PWD
Definition dinamo.h:576
#define GET_LOG_END_FULL
Definition dinamo.h:1523
int AAP_API DGetStatLogSize(HSESSIONCTX hSession, DWORD *pdwLogLen)
int AAP_API DGetStatLog(HSESSIONCTX hSession, DWORD dwStart, DWORD dwOffset, DWORD *pdwLogSize, BYTE **ppbLog)
void *AAP_API DAlloc(DWORD dwsize)
void AAP_API DFree(void *p)
int AAP_API DOpenSession(HSESSIONCTX *phSession, DWORD dwParam, BYTE *pbData, DWORD dwDataLen, DWORD dwFlags)
int AAP_API DCloseSession(HSESSIONCTX *phSession, DWORD dwFlags)
int AAP_API DInitialize(DWORD dwReserved)
int AAP_API DFinalize()
Definition dinamo.h:3089
int nPort
Definition dinamo.h:3091
char szUserId[MAX_USR_LEN]
Definition dinamo.h:3092
char szAddr[MAX_ADDR_LEN]
Definition dinamo.h:3090
char szPassword[MAX_USR_PWD]
Definition dinamo.h:3093