home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / octa21fs.zip / octave / kpathsea / c-fopen.h < prev    next >
C/C++ Source or Header  |  2000-01-15  |  3KB  |  88 lines

  1. /* c-fopen.h: how to open files with fopen.
  2.  
  3. Copyright (C) 1992, 94, 95, 96 Free Software Foundation, Inc.
  4.  
  5. This library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Library General Public
  7. License as published by the Free Software Foundation; either
  8. version 2 of the License, or (at your option) any later version.
  9.  
  10. This library is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13. Library General Public License for more details.
  14.  
  15. You should have received a copy of the GNU Library General Public
  16. License along with this library; if not, write to the Free Software
  17. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
  18.  
  19. #ifndef C_FOPEN_H
  20. #define C_FOPEN_H
  21.  
  22. /* How to open a text file:  */
  23. #ifndef FOPEN_A_MODE
  24. #define FOPEN_A_MODE "a"
  25. #endif
  26.  
  27. #ifndef FOPEN_R_MODE
  28. #define FOPEN_R_MODE "r"
  29. #endif
  30.  
  31. #ifndef FOPEN_W_MODE
  32. #define FOPEN_W_MODE "w"
  33. #endif
  34.  
  35. /* How to open a binary file for reading:  */
  36. #ifndef FOPEN_RBIN_MODE
  37. #if defined (VMS) || defined (VMCMS) || defined(DOS) || defined (OS2) || defined (WIN32) || defined (__DJGPP__) || defined (__CYGWIN32__)
  38. #define    FOPEN_RBIN_MODE    "rb"
  39. #else
  40. #define    FOPEN_RBIN_MODE    "r"
  41. #endif /* not (VM/CMS or VMS or DOS or OS2 or WIN32 or __DJGPP__ or __CYGWIN32__) */
  42. #endif /* not FOPEN_RBIN_MODE */
  43.  
  44. /* How to open a binary file for writing:  */
  45. #ifndef FOPEN_WBIN_MODE
  46. #if defined (DOS) || defined (OS2) || defined (WIN32) || defined (__DJGPP__) || defined (__CYGWIN32__)
  47. #define FOPEN_WBIN_MODE "wb"
  48. #else
  49. #ifdef VMCMS
  50. #define FOPEN_WBIN_MODE "wb, lrecl=1024, recfm=f"
  51. #else
  52. #define    FOPEN_WBIN_MODE    "w"
  53. #endif /* not VM/CMS */
  54. #endif /* not (DOS or OS2 or WIN32 or DJGPP or CYGWIN32) */
  55. #endif /* not FOPEN_WBIN_MODE */
  56.  
  57. /* How to open a binary file for appending:  */
  58. #ifndef FOPEN_ABIN_MODE
  59. #if defined (DOS) || defined (OS2) || defined (WIN32) || defined (__DJGPP__) || defined (__CYGWIN32__)
  60. #define FOPEN_ABIN_MODE "ab"
  61. #else
  62. #define FOPEN_ABIN_MODE "a"
  63. #endif /* not (DOS or OS2 or WIN32 or DJGPP or CYGWIN32) */
  64. #endif /* not FOPEN_ABIN_MODE */
  65.  
  66. /* How to switch an already open file handle to binary mode.
  67.    Used on DOSISH systems when we need to switch a standard
  68.    stream, such as stdin or stdout, to binary mode.  */
  69. #include <fcntl.h>
  70. #ifdef DOSISH
  71. #include <io.h>
  72. #ifndef O_BINARY
  73. #ifdef _O_BINARY
  74. #define O_BINARY _O_BINARY
  75. #endif
  76. #endif
  77. #if defined (__DJGPP__) || defined (WIN32) || defined (__CYGWIN32__)
  78. #define SET_BINARY(f) setmode((f), O_BINARY)
  79. #endif
  80. #else  /* not DOSISH */
  81. #ifndef O_BINARY
  82. #define O_BINARY 0
  83. #endif
  84. #define SET_BINARY(f) 0
  85. #endif /* not DOSISH */
  86.  
  87. #endif /* not C_FOPEN_H */
  88.