Portál AbcLinuxu, 27. října 2025 02:06
Pravým tl. na panel -> Přidat novou položku -> Kontrola pošty
#define _GNU_SOURCE
#include <sys/time.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include <stdint.h>
#include <signal.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/stat.h>
int beep(void){
printf("\a");
fflush(stdout);
usleep(200000);
printf("\a");
fflush(stdout);
usleep(200000);
printf("\a");
fflush(stdout);
return 0;
}
void sig_handler (int sig) {
/*dummy signal handler*/
}
int main(int argc, char **argv) {
struct stat filestat;
char *pathptr;
int fd;
pathptr = getenv("MAIL");
if (pathptr == NULL) {
fprintf(stderr, "Environment variable $MAIL is not set.\n");
exit(-1);
}
if (0 != stat (pathptr, &filestat)) {
printf ("file %s does not exist\n", pathptr);
return (-1);
}
if (filestat.st_atime < filestat.st_ctime){
beep();
}
fd = open(pathptr, O_RDONLY);
if (fd == -1){
printf("Error %d (%s)\n", errno, strerror(errno));
exit(-1);
}
signal(SIGIO, sig_handler);
while (1){
fcntl(fd, F_SETLEASE, F_RDLCK);
pause();
beep();
}
close(fd);
return 0;
}
Tiskni
Sdílej:
ISSN 1214-1267, (c) 1999-2007 Stickfish s.r.o.