You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
95 lines
2.7 KiB
95 lines
2.7 KiB
//----------------------------------------------------------------------------
|
|
// Dr.Frucht Systems Ltd.
|
|
// Copyright © 2000-2016. All Rights Reserved.
|
|
// Version 2.0 3/30/2016
|
|
// Last modification: 3/30/2016
|
|
// PROJECT:
|
|
// SUBSYSTEM:
|
|
// FILE: basicEvent.cpp
|
|
// AUTHOR: gagua
|
|
// OVERVIEW
|
|
// ~~~~~~~~
|
|
// Header file of basicEvent.cpp
|
|
//----------------------------------------------------------------------------
|
|
//
|
|
#include "basicEvent.h"
|
|
|
|
|
|
void utilizeBasicEvent( basicEvent &Evt ){
|
|
if( Evt.m_pHumanReadableMsg != NULL ) {
|
|
delete( Evt.m_pHumanReadableMsg );
|
|
};
|
|
Evt.m_pHumanReadableMsg = NULL;
|
|
if( Evt.m_pEvtData != NULL ){
|
|
switch (Evt.m_eType){
|
|
case EVT_TARGET_1D:
|
|
case EVT_TARGET_2D_WHITE:
|
|
case EVT_TARGET_2D_BLACK:
|
|
case EVT_TARGET_3D_WHITE:
|
|
case EVT_TARGET_3D_BLACK: {
|
|
delete((CLIENT_EVENT*)Evt.m_pEvtData);
|
|
break;
|
|
};
|
|
default: free(Evt.m_pEvtData);
|
|
};
|
|
};
|
|
Evt.m_pEvtData = NULL;
|
|
Evt.m_eType = EVT_NOINIT;
|
|
};
|
|
void utilizeBasicEvent( basicEvent *Evt ){
|
|
if( Evt == NULL ) return;
|
|
if( Evt->m_pHumanReadableMsg != NULL ) {
|
|
delete( Evt->m_pHumanReadableMsg );
|
|
};
|
|
if( Evt->m_pEvtData != NULL ){
|
|
switch (Evt->m_eType){
|
|
case EVT_TARGET_1D:
|
|
case EVT_TARGET_2D_WHITE:
|
|
case EVT_TARGET_2D_BLACK:
|
|
case EVT_TARGET_3D_WHITE:
|
|
case EVT_TARGET_3D_BLACK: {
|
|
delete((CLIENT_EVENT*)Evt->m_pEvtData);
|
|
break;
|
|
};
|
|
default: free(Evt->m_pEvtData);
|
|
};
|
|
};
|
|
delete( Evt );
|
|
};
|
|
basicEvent *createBasicEvent(unsigned int SRC, basicEventClassID Class, basicEventTypeID Type, char *Msg, void *Data){
|
|
basicEvent *tEvent;
|
|
tEvent =(basicEvent *) malloc( sizeof( basicEvent));
|
|
if( tEvent ){
|
|
time_t t = time(NULL);
|
|
tEvent->sTS = *localtime(&t);
|
|
tEvent->m_eClass = Class;
|
|
tEvent->m_eType = Type;
|
|
tEvent->m_nDestinationUID = 0; // Broadcast
|
|
tEvent->m_nSourceUID = SRC;
|
|
tEvent->m_pEvtData = Data;
|
|
tEvent->m_pHumanReadableMsg = (char *) malloc(strlen(Msg)+1);
|
|
if( tEvent->m_pHumanReadableMsg ) {
|
|
strcpy( tEvent->m_pHumanReadableMsg, Msg );
|
|
};
|
|
};
|
|
return tEvent;
|
|
};
|
|
|
|
basicEvent *createBasicTargetedEvent(unsigned int SRC, unsigned int DST, basicEventClassID Class, basicEventTypeID Type, char *Msg, void *Data){
|
|
basicEvent *tEvent;
|
|
tEvent = (basicEvent *)malloc(sizeof(basicEvent));
|
|
if (tEvent){
|
|
time_t t = time(NULL);
|
|
tEvent->sTS = *localtime(&t);
|
|
tEvent->m_eClass = Class;
|
|
tEvent->m_eType = Type;
|
|
tEvent->m_nDestinationUID = DST;
|
|
tEvent->m_nSourceUID = SRC;
|
|
tEvent->m_pEvtData = Data;
|
|
tEvent->m_pHumanReadableMsg = (char *)malloc(strlen(Msg) + 1);
|
|
if (tEvent->m_pHumanReadableMsg) {
|
|
strcpy(tEvent->m_pHumanReadableMsg, Msg);
|
|
};
|
|
};
|
|
return tEvent;
|
|
};
|