summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2020-11-01 11:42:54 -0800
committerOri Bernstein <ori@eigenstate.org>2020-11-01 11:42:54 -0800
commitdbd54342fd66fd372f5c2edd1597019814f41c9c (patch)
treecf76f6c4109d814a7df663e38dd7fdc1a9127f12
parentb5086c1863fe10faf48ab675f503e562ec8dfcf0 (diff)
downloadplan9front-dbd54342fd66fd372f5c2edd1597019814f41c9c.tar.xz
libbio: add aux pointer to bio
This allows us to attach additional context to the biobuf so can read from some sort of data structure without a global variable.
-rw-r--r--sys/include/bio.h1
-rw-r--r--sys/man/2/bio12
2 files changed, 12 insertions, 1 deletions
diff --git a/sys/include/bio.h b/sys/include/bio.h
index 2a874de31..2c5cdc8cf 100644
--- a/sys/include/bio.h
+++ b/sys/include/bio.h
@@ -34,6 +34,7 @@ struct Biobufhdr
uchar* gbuf; /* pointer to good data in buf */
void (*errorf)(char *); /* called on error if not nil */
int (*iof)(Biobufhdr*, void *, long); /* called to do i/o */
+ void *aux; /* user data */
};
struct Biobuf
diff --git a/sys/man/2/bio b/sys/man/2/bio
index b62a5877d..8c63870cb 100644
--- a/sys/man/2/bio
+++ b/sys/man/2/bio
@@ -1,6 +1,6 @@
.TH BIO 2
.SH NAME
-Bopen, Bfdopen, Binit, Binits, Brdline, Brdstr, Bgetc, Bgetrune, Bgetd, Bungetc, Bungetrune, Bread, Bseek, Boffset, Bfildes, Blinelen, Bputc, Bputrune, Bprint, Bvprint, Bwrite, Bflush, Bterm, Bbuffered, Blethal \- buffered input/output
+Bopen, Bfdopen, Binit, Binits, Brdline, Brdstr, Bgetc, Bgetrune, Bgetd, Bungetc, Bungetrune, Bread, Bseek, Boffset, Bfildes, Blinelen, Bputc, Bputrune, Bprint, Bvprint, Bwrite, Bflush, Bterm, Bbuffered, Blethal, Biofn \- buffered input/output
.SH SYNOPSIS
.ta \w'Biobuf* 'u
.B #include <u.h>
@@ -9,6 +9,16 @@ Bopen, Bfdopen, Binit, Binits, Brdline, Brdstr, Bgetc, Bgetrune, Bgetd, Bungetc,
.br
.B #include <bio.h>
.PP
+.ft L
+.nf
+.ta \w' 'u +\w' 'u +\w' 'u +\w' 'u +\w' 'u
+typedef struct Biobufhdr Biobufhdr;
+struct Biobufhdr {
+ void *aux; /* user data */
+ ... /* internals */
+};
+.fi
+.PP
.B
Biobuf* Bopen(char *file, int mode)
.PP