API C/C++
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;
/* inicializa a biblioteca do Dinamo */
nRet = DInitialize (0);
if ( nRet!=0 ) {
printf ( "Falha na inicialização da biblioteca do Dinamo. Codigo %d\n", nRet );
goto clean;
}
printf ("Biblioteca inicializada.\n");
/* inicializa a estrutura para conexao com o 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));
/* abre um sessao encriptada e ao mesmo tempo efetuando 'bypass' no balanceamento de carga */
nRet = DOpenSession ( &hSession, SS_USER_PWD, (BYTE *)&authPwd, sizeof(authPwd), CLEAR_CONN|LB_BYPASS );
if ( nRet!=0 ) {
printf ("Erro na abertura da sessão com o Dinamo. Código %d\n", nRet);
goto clean;
}
printf ( "Sessao aberta.\n" );
/* ******************************************************* */
/* aqui comeca o tratamento para receber o log do servidor */
/* ******************************************************* */
/* obtem tamanho do LOG no servidor */
nRet = DGetStatLogSize ( hSession, &dwLogServerSize );
if ( nRet == 0 ) {
printf ("Tamanho do LOG no servidor sem formatacao: "DWORD_PRINT" byte(s).\n", dwLogServerSize);
}
if ( dwLogServerSize>0 ) {
cbLog = (BYTE *)DAlloc ( dwLogServerSize ); /* aloca memoria */
if ( cbLog ) {
/* recebe todo o conteudo do log. */
nRet = DGetStatLog (hSession, GET_LOG_START_FULL, GET_LOG_END_FULL, &dwLogSize, &cbLog );
DFree ( cbLog ); /* libera memoria */
}
}
clean:
/* fechamento da sessao */
if ( hSession )
{
DCloseSession ( &hSession, 0 );
printf ( "Sessao encerrada.\n" );
}
/* encerra a biblioteca do Dinamo */
return nRet;
}
Application Programming Interface (API) do HSM Dinamo.
void * HSESSIONCTX
Definição dinamo.h:68
#define DEFAULT_PORT
Definição dinamo.h:1934
#define DWORD_PRINT
Definição dinamo.h:55
#define CLEAR_CONN
Definição dinamo.h:572
unsigned char BYTE
Definição dinamo.h:45
#define GET_LOG_START_FULL
Definição dinamo.h:1508
#define LB_BYPASS
Definição dinamo.h:573
unsigned int DWORD
Definição dinamo.h:46
#define SS_USER_PWD
Definição dinamo.h:561
#define GET_LOG_END_FULL
Definição dinamo.h:1509
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()
Definição dinamo.h:3110
int nPort
Definição dinamo.h:3112
char szUserId[MAX_USR_LEN]
Definição dinamo.h:3113
char szAddr[MAX_ADDR_LEN]
Definição dinamo.h:3111
char szPassword[MAX_USR_PWD]
Definição dinamo.h:3114