-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c~
81 lines (65 loc) · 1.6 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#define UTIL_IMPLEMENTATION
#include "utils.h"
#include "scan.h"
#include <fcntl.h>
#define BUFFER_SIZE 128
#define DEBUG 1
int main(int argc, char *argv[])
{
char buffer[BUFFER_SIZE];
char scancodes_filename[BUFFER_SIZE];
char buffer1[BUFFER_SIZE];
char sc_buffer[BUFFER_SIZE];
int scancodes[BUFFER_SIZE];
int scancodes_num;
int len;
printstr("Domaci 1\n");
/* ucitavanje podesavanja */
printstr("Ucitavanje podesavanja\n");
load_config("scancodes.tbl","ctrl.map");
/* ucitavanjje scancodes (test) fajla*/
printstr("Unesite ime scancodes (test) fajla:\n");
len = read(0,buffer,BUFFER_SIZE);
if(DEBUG){
newline();
printstr("Ime fajla: \n");
printstr(buffer);
newline();
}
int fd = open("test1.tst", O_RDONLY);
if(fd == -1)
{
printerr("Fajl neuspesno otvoren!\n");
_exit(1);
} else {
printstr("Test fajl ucitan\n");
}
// conversion to int
int i = 0;
int x;
for(i;i<BUFFER_SIZE;i++){
buffer[0] = 0;
len = fgets(buffer, BUFFER_SIZE, fd);
x = atoi(buffer);
scancodes[i] = x;
buffer[0] = 0;
process_scancode(x,&sc_buffer);
printstr(sc_buffer);
pause();
if(x == 400){
if(DEBUG){
printstr("Stopped at:");
len = itoa(i,buffer1);
printstr(buffer1);
newline();
}
scancodes_num = i;
break;
}
}
/* ponavljamo: */
/* ucitavanje i otvaranje test fajla */
/* parsiranje fajla, obrada scanecodova, ispis */
close(fd);
_exit(0);
}