downloadlog.c
Exemplo de download de logs.
- Veja Nota sobre os exemplos.
#include <windows.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <dinamo.h> /* header do Dinamo */
#define HOST_ADDR "10.10.4.67"
#define USER_ID "master"
#define USER_PWD "12345678"
void main ()
{
int nret = 0;
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 );
exit (1);
}
printf ("Biblioteca inicializada.\n");
/* inicializa a estrutura para conexao com o Dinamo */
/* 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);
exit (1);
}
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: %d byte(s).\n",dwLogServerSize);
}
if ( dwLogServerSize>0 ) {
if ( cbLog ) {
/* recebe todo o conteudo do log. */
}
}
/* fechamento da sessao */
if ( hSession )
{
DCloseSession ( &hSession, 0 );
printf ( "Sessao encerrada.\n" );
}
/* encerra a biblioteca do Dinamo */
DFinalize ();
}