fspr_arch_file_io.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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_poll.h"
  27. /* System headers the file I/O library needs */
  28. #if APR_HAVE_FCNTL_H
  29. #include <fcntl.h>
  30. #endif
  31. #if APR_HAVE_SYS_TYPES_H
  32. #include <sys/types.h>
  33. #endif
  34. #if APR_HAVE_ERRNO_H
  35. #include <errno.h>
  36. #endif
  37. #if APR_HAVE_STRING_H
  38. #include <string.h>
  39. #endif
  40. #if APR_HAVE_STRINGS_H
  41. #include <strings.h>
  42. #endif
  43. #if APR_HAVE_DIRENT_H
  44. #include <dirent.h>
  45. #endif
  46. #ifdef HAVE_SYS_STAT_H
  47. #include <sys/stat.h>
  48. #endif
  49. #if APR_HAVE_UNISTD_H
  50. #include <unistd.h>
  51. #endif
  52. #if APR_HAVE_STDIO_H
  53. #include <stdio.h>
  54. #endif
  55. #if APR_HAVE_STDLIB_H
  56. #include <stdlib.h>
  57. #endif
  58. #if APR_HAVE_SYS_UIO_H
  59. #include <sys/uio.h>
  60. #endif
  61. #if APR_HAVE_SYS_TIME_H
  62. #include <sys/time.h>
  63. #endif
  64. #include <fsio.h>
  65. /* End System headers */
  66. #define APR_FILE_BUFSIZE 4096
  67. #if APR_HAS_LARGE_FILES
  68. #define lseek(f,o,w) lseek64(f,o,w)
  69. #define ftruncate(f,l) ftruncate64(f,l)
  70. #endif
  71. typedef struct stat struct_stat;
  72. struct fspr_file_t {
  73. fspr_pool_t *pool;
  74. int filedes;
  75. char *fname;
  76. fspr_int32_t flags;
  77. int eof_hit;
  78. int is_pipe;
  79. fspr_interval_time_t timeout;
  80. int buffered;
  81. enum {BLK_UNKNOWN, BLK_OFF, BLK_ON } blocking;
  82. int ungetchar; /* Last char provided by an unget op. (-1 = no char)*/
  83. /* if there is a timeout set, then this pollset is used */
  84. fspr_pollset_t *pollset;
  85. /* Stuff for buffered mode */
  86. char *buffer;
  87. int bufpos; /* Read/Write position in buffer */
  88. fspr_off_t dataRead; /* amount of valid data read into buffer */
  89. int direction; /* buffer being used for 0 = read, 1 = write */
  90. fspr_off_t filePtr; /* position in file of handle */
  91. #if APR_HAS_THREADS
  92. struct fspr_thread_mutex_t *thlock;
  93. #endif
  94. };
  95. struct fspr_dir_t {
  96. fspr_pool_t *pool;
  97. char *dirname;
  98. DIR *dirstruct;
  99. struct dirent *entry;
  100. };
  101. typedef struct fspr_stat_entry_t fspr_stat_entry_t;
  102. struct fspr_stat_entry_t {
  103. struct stat info;
  104. char *casedName;
  105. fspr_time_t expire;
  106. NXPathCtx_t pathCtx;
  107. };
  108. #define MAX_SERVER_NAME 64
  109. #define MAX_VOLUME_NAME 64
  110. #define MAX_PATH_NAME 256
  111. #define MAX_FILE_NAME 256
  112. #define DRIVE_ONLY 1
  113. /* If the user passes d: vs. D: (or //mach/share vs. //MACH/SHARE),
  114. * we need to fold the case to canonical form. This function is
  115. * supposed to do so.
  116. */
  117. fspr_status_t filepath_root_case(char **rootpath, char *root, fspr_pool_t *p);
  118. /* This function check to see of the given path includes a drive/volume
  119. * specifier. If the _only_ parameter is set to DRIVE_ONLY then it
  120. * check to see of the path only contains a drive/volume specifier and
  121. * nothing else.
  122. */
  123. fspr_status_t filepath_has_drive(const char *rootpath, int only, fspr_pool_t *p);
  124. /* This function compares the drive/volume specifiers for each given path.
  125. * It returns zero if they match or non-zero if not.
  126. */
  127. fspr_status_t filepath_compare_drive(const char *path1, const char *path2, fspr_pool_t *p);
  128. fspr_status_t fspr_unix_file_cleanup(void *);
  129. #endif /* ! FILE_IO_H */