Пример #1
0
void
chkmail(void)
{
	const char *mpath;
	char *p;
	char *q;
	time_t *mtp;
	struct stackmark smark;
#ifdef WINDOWS
	struct stat statb;
#else
	struct stat64 statb;
#endif

	setstackmark(&smark);
	mpath = mpathset() ? mpathval() : mailval();
	for (mtp = mailtime; mtp < mailtime + MAXMBOXES; mtp++) {
		p = padvance(&mpath, nullstr);
		if (p == NULL)
			break;
		if (*p == '\0')
			continue;
		for (q = p ; *q ; q++);
#ifdef DEBUG
		if (q[-1] != '/')
			abort();
#endif
		q[-1] = '\0';			/* delete trailing '/' */
#ifdef WINDOWS
		if (stat(p, &statb) < 0) {
#else
		if (stat64(p, &statb) < 0) {
#endif
			*mtp = 0;
			continue;
		}
		if (!changed && statb.st_mtime != *mtp) {
			outfmt(
				&errout, snlfmt,
				pathopt ? pathopt : "you have mail"
			);
		}
		*mtp = statb.st_mtime;
	}
	changed = 0;
	popstackmark(&smark);
}


void
changemail(const char *val)
{
	changed++;
}
Пример #2
0
void
chkmail(int32_t silent)
{
	int32_t i;
	const_cstring_t mpath;
	cstring_t p;
	cstring_t q;
	struct stackmark smark;
	struct stat statb;
	if (silent)
		nmboxes = 10;
	if (nmboxes == 0)
		return;
	setstackmark(&smark);
	mpath = mpathset() ? mpathval() : mailval();
	for (i = 0 ; i < nmboxes ; i++)
	{
		p = padvance(&mpath, nullstr);
		if (p == NULL)
			break;
		if (*p == '\0')
			continue;
		for (q = p ; *q ; q++);
		if (q[-1] != '/')
			abort();
		q[-1] = '\0';			/* delete trailing '/' */
#ifdef notdef /* this is what the System V shell claims to do (it lies) */
		if (stat(p, &statb) < 0)
			statb.st_mtime = 0;
		if (statb.st_mtime > mailtime[i] && ! silent)
		{
			out2str(pathopt ? pathopt : "you have mail");
			out2c('\n');
		}
		mailtime[i] = statb.st_mtime;
#else /* this is what it should do */
		if (stat(p, &statb) < 0)
			statb.st_size = 0;
		if (statb.st_size > mailtime[i] && ! silent)
		{
			out2str(pathopt ? pathopt : "you have mail");
			out2c('\n');
		}
		mailtime[i] = statb.st_size;
#endif
	}
	nmboxes = i;
	popstackmark(&smark);
}