+static char *
+ios_dev_stream_handler_normalize (const char *handler)
+{
+ if (strcmp (handler, "stdin")
+ && strcmp (handler, "stdout")
+ && strcmp (handler, "stderr"))
+ return NULL;
+
+ return strdup (handler);
+}
I think we should introduce a new flag to use in ios_open,
IOS_F_STREAM. This way, ios_open can do the following:
- If IOS_M_RDONLY & IOS_F_STREAM -> Use the stream IOD to open the given
filename.
- If IOS_M_WRONLY & IOS_F_STREAM -> Use the stream IOD to open the given
filename.
At the Poke level this translates to:
open ("foo/bar", IOS_F_STREAM & IOS_M_RDONLY)
-> Open the file foo/bar as a read-only stream.
open ("foo/bar", IOS_F_STREAM & IOS_M_WRONLY)
-> Open the file foo/bar as a write-only stream.
open ("foo/bar", IOS_F_STREAM & IOS_M_RDWR)
-> ERROR. Not possible to open a stream for both read and write.
This means that handler of the stream IOD won't ever be used, so it can
just return NULL in all cases...