home *** CD-ROM | disk | FTP | other *** search
/ PC Extra Super CD 1998 January / PCPLUS131.iso / DJGPP / V2 / DJLSR201.ZIP / src / libc / dos / io / setmode.txh < prev    next >
Encoding:
Text File  |  1996-04-26  |  1.4 KB  |  44 lines

  1. @node setmode, io
  2. @subheading Syntax
  3.  
  4. @example
  5. #include <io.h>
  6.  
  7. int setmode(int file, int mode);
  8. @end example
  9.  
  10. @subheading Description
  11.  
  12.  
  13. This function sets the mode of the given @var{file} to @var{mode}, which
  14. is either @code{O_TEXT} or @code{O_BINARY}.  It will also set the file
  15. into either cooked or raw mode accordingly, and set any @code{FILE*}
  16. objects that use this file into text or binary mode. 
  17.  
  18. When called to put @var{file} that refers to the console into binary
  19. mode, @code{setmode} will disable the generation of @code{SIGINT} when
  20. you press @kbd{Ctrl-C} (@kbd{Ctrl-Break} will still cause
  21. @code{SIGINT}), because many programs that use binary reads from the
  22. console will also want to get the @samp{^C} characters.  You can use the
  23. @code{__djgpp_set_ctrl_c} library function (@pxref{__djgpp_set_ctrl_c})
  24. if you want @kbd{Ctrl-C} to generate interrupts while console is read in
  25. binary mode.
  26.  
  27. Note that, for buffered streams (@code{FILE*}), you must call
  28. @code{fflush} (@pxref{fflush}) before @code{setmode}, or call
  29. @code{setmode} before writing anything to the file, for proper
  30. operation.
  31.  
  32. @subheading Return Value
  33.  
  34. When successful, the function will return the previous mode of the
  35. given @var{file}.  In case of failure, -1 is returned and @var{errno}
  36. is set.
  37.  
  38. @subheading Example
  39.  
  40. @example
  41. setmode(0, O_BINARY);
  42. @end example
  43.  
  44.