-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.c
More file actions
48 lines (37 loc) · 1.09 KB
/
main.c
File metadata and controls
48 lines (37 loc) · 1.09 KB
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
#include "VirtualMachine.h"
#include <stdio.h>
#include <string.h>
int main(int argc, char *argv[]){
int TickTimeMS = 100;
int Offset = 1;
while(Offset < argc){
if(0 == strcmp(argv[Offset], "-t")){
// Tick time in ms
Offset++;
if(Offset >= argc){
break;
}
if(1 != sscanf(argv[Offset],"%d",&TickTimeMS)){
fprintf(stderr,"Invalid parameter for -t of \"%s\".\n",argv[Offset]);
return 1;
}
if(0 >= TickTimeMS){
fprintf(stderr,"Invalid parameter for -t must be positive!\n");
return 1;
}
}
else{
break;
}
Offset++;
}
if(Offset >= argc){
fprintf(stderr,"Syntax Error: vm [options] module [moduleoptions]\n");
return 1;
}
if(VM_STATUS_SUCCESS != VMStart(TickTimeMS, argc - Offset, argv + Offset)){
fprintf(stderr,"Virtual Machine failed to start.\n");
return 1;
}
return 0;
}