forked from MAYHEM-Lab/cspot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathevent.c
51 lines (41 loc) · 770 Bytes
/
event.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include "event.h"
EVENT *EventCreate(unsigned char type, unsigned long host)
{
EVENT *ev;
ev = (EVENT *)malloc(sizeof(EVENT));
if (ev == NULL)
{
return (NULL);
}
memset(ev, 0, sizeof(EVENT));
ev->type = type;
ev->host = host;
return (ev);
}
void EventFree(EVENT *ev)
{
free(ev);
return;
}
int EventSetCause(EVENT *ev, unsigned long cause_host,
unsigned long long cause_seq_no)
{
if (ev == NULL)
{
return (-1);
}
ev->cause_host = cause_host;
ev->cause_seq_no = cause_seq_no;
return (1);
}
int64_t EventIndex(unsigned long host, unsigned long long seq_no)
{
int64_t ndx;
ndx = ((int64_t)host << 32) + (int64_t)seq_no;
return (ndx);
}