API C/C
HSM Dinamo
Cargando...
Buscando...
No se han encontrado entradas
download_log.c

Ejemplo de descarga de registros.

Véase la nota sobre ejemplos.
#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 "maestro"
#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 la biblioteca Dinamo */
nRet = DInitialize (0);
if ( nRet!=0 ) {
printf ( "Error al inicializar la biblioteca Dinamo. Código %d\n", nRet );
ir a limpiar;
}
printf ("Biblioteca inicializada.\n");
/* inicializa la estructura para conectarse a Dinamo */
strncpy(authPwd. szAddr, HOST_ADDR, sizeof(authPwd.szAddr));
authPwd. nPort = DEFAULT_PORT;
strncpy(authPwd.szUserId, USER_ID, sizeof(authPwd.szUserId));
strncpy(authPwd. szContraseña, USER_PWD, sizeof(authPwd.szContraseña));
/* abre una sesión encriptada evitando el balanceo de carga */
nRet = DOpenSession ( &hSession, SS_USER_PWD,(BYTE *)&authPwd, sizeof(authPwd), CLEAR_CONN|LB_BYPASS );
if ( nRet!=0 ) {
printf ("Error al abrir sesión con Dinamo. Código %d\n", nRet);
ir a limpiar;
}
printf ( "Sesión abierta.\n" );
/* ******************************************************* */
/* aquí comienza el proceso de recepción del registro del servidor */
/* ******************************************************* */
/* obtener el tamaño del LOG en el servidor */
nRet = DGetStatLogSize ( hSession, &dwLogServerSize );
if ( nRet == 0 ) {
printf ("Tamaño LOG en servidor sin formatear: "DWORD_PRINT" byte(s).\n", dwLogServerSize);
}
if ( dwLogServerSize>0 ) {
cbLog =(BYTE *)DAlloc ( dwLogServerSize ); /* asigna memoria */
if ( cbLog ) {
/* recibe todo el contenido del registro. */
nRet = DGetStatLog (hSession, GET_LOG_START_FULL, GET_LOG_END_FULL, &dwLogSize, &cbLog );
DFree ( cbLog ); /* libera memoria */
}
}
limpia:
/* cerrar la sesión */
si ( hSesión )
{
DCloseSession ( &hSession, 0 );
printf ( "Sesión cerrada.\n" );
}
/* cierra la biblioteca Dinamo */
devolver nRet;
}
Interfaz de programación de aplicaciones (API) de HSM Dinamo.
void * HSESSIONCTX
Definición dinamo.h:68
#define PUERTO_DEFAULT
Definición dinamo.h:1948
#define DWORD_PRINT
Definición dinamo.h:55
#define CLEAR_CONN
dinamoDefinición.h:587
unsigned char BYTE
Definición dinamo.h:45
#define GET_LOG_START_FULL
dinamoDefinición.h:1522
#define LB_BYPASS
dinamoDefinición.h:588
unsigned int DWORD
Definición dinamo.h:46
#define SS_USER_PWD
dinamoDefinición.h:576
#define GET_LOG_END_FULL
dinamoDefinición.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()
Definición dinamo.h:3089
int nPuerto
Definición dinamo.h:3091
char szUserId[MAX_USR_LEN]
Definición dinamo.h:3092
char szAddr[MAX_ADDR_LEN]
Definición dinamo.h:3090
char szContraseña[MAX_USR_PWD]
dinamoDefinición.h:3093