LR 1
LR 1
h>
#include <sys/stat.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <stdio.h>
#include <errno.h>
#include <fcntl.h>
if (argc != 3)
{
printf("Usage: ./lab1_1 file1.txt file2.txt\n");
return 1;
}
file1 = argv[1];
file2 = argv[2];
char buf[COUNT];
int val, total;
total = 0;
str_upper(buf,val);
return 0;
}
#include <sys/select.h>
#include <sys/time.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <stdio.h>
#include <errno.h>
if (argc != 2)
{
printf("Usage: ./lab1_2 <identifier>\n");
return 1;
}
timeout.tv_sec = 5;
timeout.tv_usec = 0;
FD_ZERO(&readfds);
FD_SET(STDIN_FILENO, &readfds);
while (1)
{
int ret = select(STDIN_FILENO + 1, &readfds, NULL, NULL,
&timeout);
err_check(&errno);
if (ret == 0)
{
fprintf(stderr, "Timeout occurred (%s)\n", identifier);
timeout.tv_sec = 5;
timeout.tv_usec = 0;
FD_ZERO(&readfds);
FD_SET(STDIN_FILENO, &readfds);
ret = select(STDIN_FILENO + 1, &readfds, NULL, NULL, &timeout);
} else if (FD_ISSET(STDIN_FILENO, &readfds))
{
char buff[COUNT];
ssize_t val = read(STDIN_FILENO, buff, COUNT);
err_check(&errno);
return 0;
}