fspr_arch_file_io.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. /* Licensed to the Apache Software Foundation (ASF) under one or more
  2. * contributor license agreements. See the NOTICE file distributed with
  3. * this work for additional information regarding copyright ownership.
  4. * The ASF licenses this file to You under the Apache License, Version 2.0
  5. * (the "License"); you may not use this file except in compliance with
  6. * the License. You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #ifndef FILE_IO_H
  17. #define FILE_IO_H
  18. #include "fspr.h"
  19. #include "fspr_private.h"
  20. #include "fspr_general.h"
  21. #include "fspr_tables.h"
  22. #include "fspr_file_io.h"
  23. #include "fspr_file_info.h"
  24. #include "fspr_errno.h"
  25. #include "fspr_lib.h"
  26. #include "fspr_thread_mutex.h"
  27. #ifndef WAITIO_USES_POLL
  28. #include "fspr_poll.h"
  29. #endif
  30. /* System headers the file I/O library needs */
  31. #if APR_HAVE_FCNTL_H
  32. #include <fcntl.h>
  33. #endif
  34. #if APR_HAVE_SYS_TYPES_H
  35. #include <sys/types.h>
  36. #endif
  37. #if APR_HAVE_ERRNO_H
  38. #include <errno.h>
  39. #endif
  40. #if APR_HAVE_STRING_H
  41. #include <string.h>
  42. #endif
  43. #if APR_HAVE_STRINGS_H
  44. #include <strings.h>
  45. #endif
  46. #if APR_HAVE_DIRENT_H
  47. #include <dirent.h>
  48. #endif
  49. #ifdef HAVE_SYS_STAT_H
  50. #include <sys/stat.h>
  51. #endif
  52. #if APR_HAVE_UNISTD_H
  53. #include <unistd.h>
  54. #endif
  55. #if APR_HAVE_STDIO_H
  56. #include <stdio.h>
  57. #endif
  58. #if APR_HAVE_STDLIB_H
  59. #include <stdlib.h>
  60. #endif
  61. #if APR_HAVE_SYS_UIO_H
  62. #include <sys/uio.h>
  63. #endif
  64. #if APR_HAVE_SYS_TIME_H
  65. #include <sys/time.h>
  66. #endif
  67. #ifdef BEOS
  68. #include <kernel/OS.h>
  69. #endif
  70. #if BEOS_BONE
  71. # ifndef BONE7
  72. /* prior to BONE/7 fd_set & select were defined in sys/socket.h */
  73. # include <sys/socket.h>
  74. # else
  75. /* Be moved the fd_set stuff and also the FIONBIO definition... */
  76. # include <sys/ioctl.h>
  77. # endif
  78. #endif
  79. /* End System headers */
  80. #define APR_FILE_BUFSIZE 4096
  81. struct fspr_file_t {
  82. fspr_pool_t *pool;
  83. int filedes;
  84. char *fname;
  85. fspr_int32_t flags;
  86. int eof_hit;
  87. int is_pipe;
  88. fspr_interval_time_t timeout;
  89. int buffered;
  90. enum {BLK_UNKNOWN, BLK_OFF, BLK_ON } blocking;
  91. int ungetchar; /* Last char provided by an unget op. (-1 = no char)*/
  92. #ifndef WAITIO_USES_POLL
  93. /* if there is a timeout set, then this pollset is used */
  94. fspr_pollset_t *pollset;
  95. #endif
  96. /* Stuff for buffered mode */
  97. char *buffer;
  98. int bufpos; /* Read/Write position in buffer */
  99. unsigned long dataRead; /* amount of valid data read into buffer */
  100. int direction; /* buffer being used for 0 = read, 1 = write */
  101. fspr_off_t filePtr; /* position in file of handle */
  102. #if APR_HAS_THREADS
  103. struct fspr_thread_mutex_t *thlock;
  104. #endif
  105. };
  106. #if APR_HAS_LARGE_FILES && defined(_LARGEFILE64_SOURCE)
  107. #define stat(f,b) stat64(f,b)
  108. #define lstat(f,b) lstat64(f,b)
  109. #define fstat(f,b) fstat64(f,b)
  110. #define lseek(f,o,w) lseek64(f,o,w)
  111. #define ftruncate(f,l) ftruncate64(f,l)
  112. typedef struct stat64 struct_stat;
  113. #else
  114. typedef struct stat struct_stat;
  115. #endif
  116. struct fspr_dir_t {
  117. fspr_pool_t *pool;
  118. char *dirname;
  119. DIR *dirstruct;
  120. struct dirent *entry;
  121. };
  122. fspr_status_t fspr_unix_file_cleanup(void *);
  123. mode_t fspr_unix_perms2mode(fspr_fileperms_t perms);
  124. fspr_fileperms_t fspr_unix_mode2perms(mode_t mode);
  125. #endif /* ! FILE_IO_H */