-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
56 lines (40 loc) · 1.36 KB
/
main.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
52
53
54
55
56
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include "SMlib.h"
int main(void)
{
printf("\nSTART\n");
stateMachineCTX* SM_CTX = SMlib_createCTX();
SMlib_initCTX(SM_CTX);
SMlib_printCurrentState(SM_CTX);
SMlib_printStatesGraphEdge(SM_CTX);
SMlib_printLunsAccessTable(SM_CTX);
stateIndexCode newState = S1;
switchResult resultCode = SMlib_switchState(SM_CTX, newState);
switch (resultCode)
{
case SWITCH_SUCCESS:
printf("\nSUCCESS: now state is %i\n", newState);
break;
case SWITCH_ERROR_STATE_DOES_NOT_EXIST:
printf("\nERROR: state with index %i does not exist\n", newState);
break;
case SWITCH_ERROR_NO_DIRECT_WAY:
printf("\nERROR: no direct way from %i to %i\n", SMlib_getCurrentState(SM_CTX), newState);
break;
case SWITCH_ERROR_EXTERNAL_ACTION_FAIL:
printf("\nERROR: external action failed, switching from %i to %i has been stopped\n",
SMlib_getCurrentState(SM_CTX), newState);
break;
// TODO: implement in future
// case SWITCH_ERROR_HMAC_ERROR:
// break;
default:
break;
}
SMlib_destroyCTX(SM_CTX);
printf("\nSize %i bytes\n", SMlib_getSizeofCTX());
printf("\nEND\n");
return 0;
}