Example of receiving logs in real time.
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#define HOST_ADDR "127.0.0.1"
#define USER_ID "master"
#define USER_PWD "12345678"
#define FILE_NAME "./dinamo.log"
int AAP_API ReceiveLogsCallback(
char *szEvent,
void * pParam,
BOOL bFinal)
{
int nRet = 0;
FILE *pFile = (FILE *)pParam;
if (pFile){
nRet = fprintf(pFile, "%s\n", szEvent);
nRet = fprintf(stdout, "%s\n", szEvent);
}
if (bFinal){
fclose(pFile);
pFile = NULL;
}
return nRet;
}
int main()
{
int nRet;
FILE *pFile = NULL;
if (nRet){
printf("Falha na funcao: DInitialize \nCodigo de erro: %d\n",nRet);
goto clean;
}
printf("Bibliotecas inicializadas.\n");
strncpy(authPwd.szAddr, HOST_ADDR, sizeof(authPwd.szAddr));
strncpy(authPwd.szUserId, USER_ID, sizeof(authPwd.szUserId));
strncpy(authPwd.szPassword, USER_PWD, sizeof(authPwd.szPassword));
if (nRet){
printf("Falha na funcao: DOpenSession \nCodigo de erro: %d\n",nRet);
goto clean;
}
printf("Sessao com o HSM estabelecida.\n");
pFile = fopen(FILE_NAME, "wt");
if (pFile == NULL){
printf("Falha na funcao: fopen\n");
goto clean;
}
printf("----INICIO----");
if (nRet){
printf("Falha na funcao: DGetLogEvents \nCodigo de erro: %d\n",nRet);
goto clean;
}
printf("----FIM----");
clean:
if (pFile){
fclose(pFile);
printf("Arquivo de log fechado.\n");
}
if (hSession) {
printf("Sessao encerrada.\n");
}
printf("Bibliotecas finalizada.\n");
return nRet;
}
Application Programming Interface (API) do HSM Dinamo.
int BOOL
Definição dinamo.h:49
void * HSESSIONCTX
Definição dinamo.h:68
#define DEFAULT_PORT
Definição dinamo.h:1949
unsigned char BYTE
Definição dinamo.h:45
#define AAP_API
Definição dinamo.h:42
#define ENCRYPTED_CONN
Definição dinamo.h:585
#define SS_USER_PWD
Definição dinamo.h:576
int AAP_API DGetLogEvents(HSESSIONCTX hSession, funcLogEventCallback fncallback, void *pParam)
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)