summaryrefslogtreecommitdiff
path: root/usr.bin/aucat/pipe.c
diff options
context:
space:
mode:
authorAlexandre Ratchov <ratchov@cvs.openbsd.org>2010-04-03 17:40:34 +0000
committerAlexandre Ratchov <ratchov@cvs.openbsd.org>2010-04-03 17:40:34 +0000
commit1f1e75a96689e478cf3357f495812c131cb352f9 (patch)
tree4c0138208ad43819ad172abac04aa95589e6b6e9 /usr.bin/aucat/pipe.c
parent148d5c4d2674e507ae720da1aa37065cf06a01db (diff)
doc fixes from jmc
Diffstat (limited to 'usr.bin/aucat/pipe.c')
-rw-r--r--usr.bin/aucat/pipe.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/usr.bin/aucat/pipe.c b/usr.bin/aucat/pipe.c
index 76f98baa832..065f6f0ad7a 100644
--- a/usr.bin/aucat/pipe.c
+++ b/usr.bin/aucat/pipe.c
@@ -139,3 +139,54 @@ pipe_close(struct file *file)
close(f->fd);
}
+
+off_t
+pipe_endpos(struct file *file)
+{
+ struct pipe *f = (struct pipe *)file;
+ off_t pos;
+
+ pos = lseek(f->fd, 0, SEEK_END);
+ if (pos < 0) {
+#ifdef DEBUG
+ file_dbg(&f->file);
+ dbg_puts(": couldn't get file size\n");
+#endif
+ return 0;
+ }
+ return pos;
+}
+
+int
+pipe_seek(struct file *file, off_t pos)
+{
+ struct pipe *f = (struct pipe *)file;
+ off_t newpos;
+
+ newpos = lseek(f->fd, pos, SEEK_SET);
+ if (newpos < 0) {
+#ifdef DEBUG
+ file_dbg(&f->file);
+ dbg_puts(": couldn't seek\n");
+#endif
+ /* XXX: call eof() */
+ return 0;
+ }
+ return 1;
+}
+
+int
+pipe_trunc(struct file *file, off_t pos)
+{
+ struct pipe *f = (struct pipe *)file;
+
+ if (ftruncate(f->fd, pos) < 0) {
+#ifdef DEBUG
+ file_dbg(&f->file);
+ dbg_puts(": couldn't truncate file\n");
+#endif
+ /* XXX: call hup() */
+ return 0;
+ }
+ return 1;
+}