Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ fdopen(3C) — DG/UX 4.00

Media Vault

Software Library

Restoration Projects

Artifacts Sought



                                                               fdopen(3C)



        _________________________________________________________________
        fdopen                                                   function
        Associate a buffered I/O stream with a DG/UX file descriptor.
        _________________________________________________________________


        Calling Sequence

        #include <stdio.h>
        FILE *stream, *fdopen();
        int fd;
        char *options;
        stream = fdopen(fd, options);


        where
             fd is a UNIX file descriptor (returned with creat, dup,
             open, etc.).

             options is a byte pointer to a string specifying the
             standard opening types (all are UNIX compatible):

         a     Open for appending only.
         a+    Open for appending (read and write).
         r     Open for reading only.
         r+    Open for read/write access.  Return an error if the file
               does not exist.
         w     Open for writing only.
         w+    Delete, re-create, and open a file for read/write access.

        or one of the additional Data General opening types:

           b     Open for block I/O.
           j     Open for binary read.
           k     Open for binary write.
           s     Open for shared page I/O.
           u     Open for updating.
           x     Open file exclusively for updating.



        Description

        Use the fdopen function to associate a buffered I/O stream with a
        UNIX file descriptor.  As long as your file is a disk file, you
        need not take any special action to alternate between reading and
        writing.  The I/O routines correctly switch from one mode to the
        other.

        If your program will run under other C compilers, or if the file
        is not a disk file, you might have to use an fseek(stream, 0L, 1)



        DG/UX 4.00                                                 Page 1
               Licensed material--property of copyright holder(s)





                                                               fdopen(3C)



        when switching I/O types.


        Returns

        The fdopen function returns a null if an opening error occurs.


        Related Functions

        See also the fopen function description.


        Example

        #include <stdio.h>

        main() {
            int   dup(), fd;
            FILE *fp, *fdopen();
            char ch;


            fd = dup(fileno(stdin));
            fp = fdopen(fd, "r");
            fclose(stdin);

            while ((ch = getc(fp)) != EOF)
                putchar(ch);
        }
























        DG/UX 4.00                                                 Page 2
               Licensed material--property of copyright holder(s)



Typewritten Software • bear@typewritten.org • Edmonds, WA 98026