?? lib.mail.c
字號:
#include <sys/types.h>#include <sys/stat.h>#include <unistd.h>#include <stdio.h>#include <signal.h>#include <syslog.h>#define SLEEP_TIME 5//get the mail sizelong get_file_size(const char* filename) { struct stat status; long size; if(stat(filename,&status)==-1){ perror("cannot get the file status"); return -1; } size=status.st_size; return size; } void mail_log(const char* progname,const char* mail_pos){ fprintf(stderr,"%s notice: You hava new mail in %s\n",progname,mail_pos);}int check_mail(const char *filename,const char* progname) { long old_mail_size; long mail_size; old_mail_size=get_file_size(filename); if(old_mail_size==-1) return 1; if(old_mail_size>0) mail_log(progname,filename); sleep(SLEEP_TIME); while(1){ mail_size=get_file_size(filename); if(mail_size!=old_mail_size){ mail_log(progname,filename); } old_mail_size=mail_size; sleep(SLEEP_TIME); } }
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -