summaryrefslogtreecommitdiff
path: root/usr.bin/calendar
diff options
context:
space:
mode:
authorPaul Janzen <pjanzen@cvs.openbsd.org>2001-09-03 16:15:09 +0000
committerPaul Janzen <pjanzen@cvs.openbsd.org>2001-09-03 16:15:09 +0000
commita9cbbd0e8e075ef2c18e6a9922af055f1ddd3ead (patch)
tree1f620941c39ec70b6898c359bded5a986213fc06 /usr.bin/calendar
parentc9f1cc32a6ebedf2f029f87bb8020fdcdea220c6 (diff)
No longer any reason to care if calendar file is a pipe or not.
Diffstat (limited to 'usr.bin/calendar')
-rw-r--r--usr.bin/calendar/io.c36
1 files changed, 5 insertions, 31 deletions
diff --git a/usr.bin/calendar/io.c b/usr.bin/calendar/io.c
index 6040f82096d..163dfe469ae 100644
--- a/usr.bin/calendar/io.c
+++ b/usr.bin/calendar/io.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: io.c,v 1.13 2001/09/03 15:53:00 pjanzen Exp $ */
+/* $OpenBSD: io.c,v 1.14 2001/09/03 16:15:08 pjanzen Exp $ */
/*
* Copyright (c) 1989, 1993, 1994
@@ -43,7 +43,7 @@ static const char copyright[] =
#if 0
static const char sccsid[] = "@(#)calendar.c 8.3 (Berkeley) 3/25/94";
#else
-static char rcsid[] = "$OpenBSD: io.c,v 1.13 2001/09/03 15:53:00 pjanzen Exp $";
+static char rcsid[] = "$OpenBSD: io.c,v 1.14 2001/09/03 16:15:08 pjanzen Exp $";
#endif
#endif /* not lint */
@@ -53,11 +53,11 @@ static char rcsid[] = "$OpenBSD: io.c,v 1.13 2001/09/03 15:53:00 pjanzen Exp $";
#include <sys/types.h>
#include <sys/uio.h>
#include <sys/wait.h>
-#include <sys/file.h>
#include <ctype.h>
#include <err.h>
#include <errno.h>
+#include <fcntl.h>
#include <locale.h>
#include <pwd.h>
#include <stdio.h>
@@ -81,8 +81,6 @@ struct iovec header[] = {
};
-int openf(char *path);
-
void
cal()
{
@@ -289,30 +287,6 @@ getfield(p, endp, flags)
return (val);
}
-char path[MAXPATHLEN];
-
-int
-openf(path)
- char *path;
-{
- struct stat st;
- int fd;
-
- fd = open(path, O_RDONLY|O_NONBLOCK);
- if (fd == -1)
- return (-1);
- if (fstat(fd, &st) == -1) {
- close(fd);
- return (-1);
- }
- if ((st.st_mode & S_IFMT) != S_IFREG) {
- close (fd);
- return (-1);
- }
-
- fcntl(fd, F_SETFD, fcntl(fd, F_GETFD, 0) &~ O_NONBLOCK);
- return (fd);
-}
FILE *
opencal()
@@ -321,14 +295,14 @@ opencal()
int fdin;
/* open up calendar file as stdin */
- if ((fdin = openf(calendarFile)) == -1) {
+ if ((fdin = open(calendarFile, O_RDONLY)) == -1) {
if (!doall) {
char *home = getenv("HOME");
if (home == NULL || *home == '\0')
errx(1, "cannot get home directory");
if (!(chdir(home) == 0 &&
chdir(calendarHome) == 0 &&
- (fdin = openf(calendarFile)) != -1))
+ (fdin = open(calendarFile, O_RDONLY)) != -1))
errx(1, "no calendar file: ``%s'' or ``~/%s/%s",
calendarFile, calendarHome, calendarFile);
}