2020-03-30 00:40:59 +02:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <fcntl.h>
|
2019-12-06 23:45:04 +01:00
|
|
|
|
2020-03-30 00:40:59 +02:00
|
|
|
int main(int argc, char **argv)
|
2019-12-06 23:45:04 +01:00
|
|
|
{
|
2020-03-28 19:52:59 +01:00
|
|
|
char c[1024];
|
|
|
|
int ret;
|
|
|
|
int fd;
|
|
|
|
|
2020-03-30 00:40:59 +02:00
|
|
|
// Check parameters
|
|
|
|
for (int i = 0 ; i < argc ; i++)
|
|
|
|
printf("argv[%d]: %s\n", i, argv[i]);
|
2020-04-21 20:56:27 +02:00
|
|
|
for(int i = 0 ; i < 1000000 ; ++i);
|
2020-03-30 00:40:59 +02:00
|
|
|
|
|
|
|
// Read test
|
2020-03-28 19:52:59 +01:00
|
|
|
fd = open("/mnt/casio/VHEX/text.txt", O_RDONLY);
|
|
|
|
if (fd < 0) {
|
|
|
|
dprintf(STDERR_FILENO, "unable to open test file\n");
|
|
|
|
return (84);
|
|
|
|
}
|
|
|
|
|
2020-04-21 20:56:27 +02:00
|
|
|
// DIsplay file
|
2020-03-28 19:52:59 +01:00
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
ret = read(fd, c, 1024);
|
|
|
|
if (ret <= 0)
|
|
|
|
break;
|
|
|
|
write(STDOUT_FILENO, c, ret);
|
|
|
|
}
|
2020-04-21 20:56:27 +02:00
|
|
|
|
|
|
|
// Wait signal
|
|
|
|
// TODO: better signal management (kernel)
|
|
|
|
printf("wait signal....\n");
|
|
|
|
while (read(STDIN_FILENO, c, 3) != 4);
|
2020-03-28 19:52:59 +01:00
|
|
|
return (0);
|
2020-02-05 21:09:39 +01:00
|
|
|
}
|