[mod.std.c] mod.std.c Digest V8#5

osd@hou2d.UUCP (Orlando Sotomayor-Diaz) (07/11/85)

From: Orlando Sotomayor-Diaz (The Moderator) <cbosgd!std-c>


mod.std.c Digest            Wed, 10 Jul 85       Volume 8 : Issue   5 

Today's Topics:
                        flag to fopen (2 msgs)
----------------------------------------------------------------------

Date: Thu, 4 Jul 85 13:11:14 mst
From: ihnp4!arizona!wendt (Alan Wendt)
Subject: flag to fopen
To: ihnp4!cbosgd!std-c, wendt

> Every C compiler for another operating system has had to implement
> a flag to fopen where the application programmer specifies whether
> the file is a text file or a binary file.

I prefer a call which can be made on a file descriptor to do such a
declaration.  This call (ie "texfile(&stdout)") can be embedded inside
printf and other places and then most applications can run unchanged.

Moreover, this method allows standard input and output to be either
text or binary, whereas requiring the flag on fopen pretty much
forces standard I/O files to be text.

Moreover, consider maintaining a program that is to run on CP/M and UNIX.
If fopen takes unique flags I have to conditionally compile every
fopen call.  With a separate function call I simply define a null
function for UNIX and I don't have to conditionally compile anything
except that function (even if printf does no textfile calls).

Alan Wendt
arizona!wendt

------------------------------

Date: Tue, 9 Jul 85 15:11:03 edt
From: mark@cbosgd.ATT.UUCP (Mark Horton)
Subject: flag to fopen
To: arizona!wendt@ihnp4.uucp, osd@hou2d.uucp

I was not recommending a particular way of doing it, just pointing
out the need for the application to communicate to the implementation
whether the file is text or not.  A modifier would probably do OK,
unless some presentation protocol had to be negotiated at fopen time
over a network connection.  Presumably on UNIX there might be some
way to communicate this to the raw file descriptor (e.g. an ioctl)
if the presentation layer is in the kernel (which it may be with
System V streams.)  Your point about stdout assuming text is quite
valid, I can only observe that that's the way most micro implementations
seem to handle it today, perhaps they wanted to avoid another function.
In any case, standardizing the method would be a win.

	Mark

------------------------------

End of mod.std.c Digest - Wed, 10 Jul 85 19:30:10 EDT
******************************
USENET -> posting only through cbosgd!std-c.
ARPA -> ... through cbosgd!std-c@BERKELEY.ARPA (NOT to INFO-C)
In all cases, you may also reply to the author(s) above.