-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.c
73 lines (56 loc) · 1.1 KB
/
test.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
#include <stdio.h>
#include <unistd.h>
#include "yalog.h"
int
newlog(int fd) {
int retval;
retval = yalogfd(fd);
if (retval < 0)
printf("Error creating log with fd %d\n", fd);
else
printf("Added log with fd %d on index %d\n", fd, retval);
return retval;
}
int
dellog(int index) {
int retval;
if ((retval = endlog(index)) < 0)
printf("Error deleting log with index %d\n", index);
else
printf("Deleted log with index %d\n", index);
return retval;
}
int
endlogs() {
int retval;
if ((retval = delyalog()) > 0) {
printf("Error closing logs : %d\n", retval);
return -1;
}
printf("Closed all logs correctly\n");
return 0;
}
int
main(void) {
int logs[5];
printf("Add three logs: \n");
logs[0] = newlog(1);
logs[1] = newlog(2);
logs[2] = newlog(3);
showlogs();
printf("\n");
printf("Erase log 1: \n");
dellog(logs[1]);
showlogs();
/*
printf("\n");
printf("Erase log 3: \n");
dellog(3);
showlogs();
printf("\n");
printf("Add one log: \n");
logs[3] = newlog(4);
showlogs();*/
endlogs();
return 0;
}