#include <errno.h>
#include <paths.h>
#include "mbox.h"
+#include "optdefs.h"
#define FOLDERS_DELTA 5
}
}
-void watch_folders(int opt_bell)
+void watch_folders(int opt_flags)
{
unsigned int i;
int newmail = 0;
for (i=0; i < numfolders; i++)
- newmail |= watch_mbox(folders[i]->path, folders[i]->prefix, &folders[i]->size);
+ newmail |= watch_mbox(folders[i]->path, folders[i]->prefix, &folders[i]->size, opt_flags);
- if (newmail && opt_bell) {
+ if (newmail && (opt_flags & OPT_BELL)) {
putchar('\007');
fflush(stdout);
}
void fix_prefix();
-void watch_folders(int opt_bell);
+void watch_folders(int opt_flags);
return dest;
}
-int inspect_mbox(char *path, char *prefix, off_t size)
+int inspect_mbox(char *path, char *prefix, off_t size, int opt_flags)
{
FILE *f;
char buf[HDR_LEN];
return newmail;
}
-int watch_mbox(char *path, char *prefix, off_t *size)
+int watch_mbox(char *path, char *prefix, off_t *size, int opt_flags)
{
struct stat st;
int newmail = 0;
if (stat(path, &st) == 0) {
if (st.st_size > *size)
if (access(path, R_OK) == 0) {
- newmail = inspect_mbox(path, prefix, *size);
+ newmail = inspect_mbox(path, prefix, *size, opt_flags);
}
*size = st.st_size;
return newmail;
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-off_t watch_mbox(char *path, char *prefix, off_t *size);
+off_t watch_mbox(char *path, char *prefix, off_t *size, int opt_flags);
#include <unistd.h>
#include <signal.h>
#include "folder.h"
+#include "optdefs.h"
#include "version.h"
void usage()
int main(int argc, char *argv[])
{
- int opt_bell = 0;
+ int opt_flags = 0;
unsigned int opt_interval = 60;
- int opt_window = 0;
- int opt_raw = 0;
int c;
int tmp_i;
while ((c = getopt(argc, argv, "bhi:rw")) != -1) {
switch (c) {
case 'b':
- opt_bell = 1;
+ opt_flags |= OPT_BELL;
break;
case 'h':
usage();
fprintf(stderr, "Interval not greater as zero, ignoring\n");
break;
case 'r':
- opt_raw = 1;
+ opt_flags |= OPT_RAW;
break;
case 'w':
- opt_window = 1;
+ opt_flags |= OPT_WINDOW;
break;
}
}
add_folder(argv[optind++]);
fix_prefix();
- if (!opt_window) {
+ if (!(opt_flags & OPT_WINDOW)) {
if (fork())
return 0;
while (1) {
/* Loop over all files */
- watch_folders(opt_bell);
+ watch_folders(opt_flags);
/* wait for the next incarnation */
sleep(opt_interval);
--- /dev/null
+/*
+ Copyright (c) 2004 Joey Schulze <joey@infodrom.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#define OPT_BELL 0x01
+#define OPT_WINDOW 0x02
+#define OPT_RAW 0x04