home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c065 / 1.ddi / INCLUDE.ZIP / FILESYS.H < prev    next >
Encoding:
C/C++ Source or Header  |  1990-06-07  |  2.6 KB  |  74 lines

  1. /*
  2.     filesys.h -- interface to file system
  3. */
  4.  
  5. /*[]------------------------------------------------------------[]*/
  6. /*|                                                              |*/
  7. /*|     Turbo C Run Time Library - Version 3.0                   |*/
  8. /*|                                                              |*/
  9. /*|                                                              |*/
  10. /*|     Copyright (c) 1987, 1990 by Borland International        |*/
  11. /*|     All Rights Reserved.                                     |*/
  12. /*|                                                              |*/
  13. /*[]------------------------------------------------------------[]*/
  14.  
  15.  
  16. /*
  17.  * The following declarations will need to be adjusted for the
  18.  * operating system in use.
  19.  *
  20.  * We assume a Unix-like model.  If yours is very different, additional
  21.  * interface functions will be needed, or some rewriting of the
  22.  * implementation which uses these functions and data.
  23.  */
  24.  
  25. #include <fcntl.h>
  26. #include <sys/stat.h>
  27. #include <io.h>
  28.  
  29. // Assume the following OS routines return this value on error,
  30. // and that this value is NOT ZERO.
  31. // Assume they also set errno when needed.
  32. const int OS_err = -1;    
  33.  
  34. // open file, return fd, open mode 'how', protection 'prot'
  35. //extern "C" int open(const char *name, int how, int prot);
  36. // 'how' bits, these values for SUN OS (like BSD Unix)
  37. const int O_rdonly = O_RDONLY;    // read only
  38. const int O_wronly = O_WRONLY;    // write only
  39. const int O_rdwr   = O_RDWR;    // read and write
  40. const int O_append = O_APPEND;    // append at each write
  41. const int O_create = O_CREAT;    // create file if it does not exist
  42. const int O_trunc  = O_TRUNC;    // truncate file length to 0 if exists
  43. const int O_excl   = O_EXCL;    // error if create and file exists
  44.  
  45. // close file, return 0 on success
  46. //extern "C" int close(int fd);
  47.  
  48. // read 'count' chars into 'buf', return number read
  49. //extern "C" int read(int fd, void* buf, unsigned count);
  50.  
  51. // write 'count' chars from 'buf', return number written
  52. //extern "C" int write(int fd, void* buf, unsigned count);
  53.  
  54. // seek to 'offset' relative to 'whence',
  55. // return new file position, long(OS_err) on error (set errno)
  56. //extern "C" long lseek(int fd, long offset, int whence);
  57. // values for 'whence':
  58. const int L_set = SEEK_SET;    // from beginning
  59. const int L_cur = SEEK_CUR;    // from current pos
  60. const int L_end = SEEK_END;    // from end
  61.  
  62.  
  63. // natural size for a file buffer, plus 4 for putback
  64. const int B_size = 516;
  65.  
  66. // default protection bits
  67. const int P_default = S_IREAD | S_IWRITE;
  68.  
  69.  
  70. // fd numbers for standard in, out, error
  71. const int F_stdin = 0;
  72. const int F_stdout = 1;
  73. const int F_stderr = 2;
  74.