From b71ea9536dc757dcb0732e34e2d00f0eb0c1c514 Mon Sep 17 00:00:00 2001 From: Kelvin Sherlock Date: Sun, 6 May 2012 17:41:45 -0400 Subject: [PATCH] ioctl(2) --- mioctl.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 mioctl.c diff --git a/mioctl.c b/mioctl.c new file mode 100644 index 0000000..f2ba168 --- /dev/null +++ b/mioctl.c @@ -0,0 +1,46 @@ +#include "marignotti.h" +#include +#include + +#include + +#pragma noroot +#pragma optimize 79 + +int mioctl(Entry *e, void *p1, void *p2, void *p3, void *p4, void *p5) +{ + Word t; + Word terr; + + LongWord tioc = *(LongWord *)p1; + void *data = (void *)p3; + + if (tioc == FIONREAD) + { + // return # of bytes available + IncBusy(); + terr = TCPIPStatusTCP(e->ipid, &e->sr); + t = _toolErr; + DecBusy(); + if (t) terr = t; + + if (data) *(Word *)data = e->sr.srRcvQueued; + + return 0; + } + + if (tioc == FIONBIO) + { + // set/clear non-blocking io. + int tmp; + + tmp = data ? *(int *)data : 0; + e->_NONBLOCK = tmp ? 1 : 0; + return 0; + } + + // SIOCSHIWAT / SIOCGHIWAT ? + // SIOCSLOWAT / SIOCGLOWAT ? + + return EINVAL; +} \ No newline at end of file