Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ setmode(DOS) — OpenDesktop Software Development System 1.0.0d

Media Vault

Software Library

Restoration Projects

Artifacts Sought

     Name
          setmode - Sets translation mode.

     Syntax
          #include <fcntl.h>
          #include <io.h>

          int setmode(handle, mode)
          int handle;
          int mode;

     Description
          The setmode function sets the translation mode of the file
          given by handle to mode. The mode must be one of the
          following manifest constants:

            Constant   Meaning

            O_TEXT     Set text (translated) mode.
                       Carriage-return/line-feed
                       combinations (CR-LF) are translated
                       into a single line feed (LF) on
                       input. Line-feed characters are
                       translated into CR-LF combinations on
                       output.

            O_BINARY   Set binary (untranslated) mode. The
                       above translations are suppressed.

          The setmode function is typically used to modify the default
          translation mode of stdin, stdout, stderr, stdaux, and
          stdprn, but can be used on any file.

     Return Value
          If successful, setmode returns the previous translation
          mode. A return value of -1 indicates an error, and errno is
          set to one of the following values:

            Value    Meaning

            EBADF    Invalid file handle

            EINVAL   Invalid mode argument (neither O_TEXT
                     nor O_BINARY)

     See Also
          creat(DOS), fopen(DOS), open(DOS)

     Example
          #include <stdio.h> #include <fcntl.h> #include <io.h>

          int result;

          main()
           {
                  /* Set "stdin" to have binary mode   */
                  /* (Initially "stdin" is in text mode): */
                  result = setmode(fileno(stdin),O_BINARY);
                  if ( result == -1 )
                          perror("Cannot set mode");
                  else
                          printf("'stdin' successfully changed to");
                          printf(" binary mode\n");
           }

          This program uses setmode to change stdin from text mode to
          binary mode.

                                                (printed 6/18/89)



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