You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

194 lines
4.5 KiB

  1. --- a/configure.ac
  2. +++ b/configure.ac
  3. @@ -42,7 +42,7 @@ DAV_CHECK_NEON
  4. # Checks for header files.
  5. AC_HEADER_DIRENT
  6. AC_HEADER_STDC
  7. -AC_CHECK_HEADERS([fcntl.h libintl.h langinfo.h limits.h locale.h mntent.h stddef.h stdint.h stdlib.h string.h sys/file.h sys/mount.h sys/time.h syslog.h termios.h unistd.h utime.h])
  8. +AC_CHECK_HEADERS([error.h fcntl.h libintl.h langinfo.h limits.h locale.h mntent.h stddef.h stdint.h stdlib.h string.h sys/file.h sys/mount.h sys/time.h sys/select.h sys/types.h syslog.h termios.h unistd.h utime.h])
  9. # Checks for typedefs, structures, and compiler characteristics.
  10. AC_C_CONST
  11. @@ -78,7 +78,7 @@ AC_FUNC_SELECT_ARGTYPES
  12. AC_FUNC_STRFTIME
  13. AC_FUNC_STAT
  14. AC_FUNC_UTIME_NULL
  15. -AC_CHECK_FUNCS([endpwent ftruncate getmntent memset mkdir nl_langinfo rpmatch select setlocale strcasecmp strchr strdup strerror strpbrk strrchr strstr strtol strtoull utime])
  16. +AC_CHECK_FUNCS([endpwent ftruncate getmntent memset mkdir nl_langinfo rpmatch select setlocale strcasecmp strchr strdup strerror strpbrk strrchr strstr strtol strtoull utime canonicalize_file_name fopencookie])
  17. # Misc.
  18. DAV_DEFAULTS
  19. --- a/src/cache.c
  20. +++ b/src/cache.c
  21. @@ -19,12 +19,12 @@
  22. #include "config.h"
  23. +#include "compat.h"
  24. #ifdef HAVE_DIRENT_H
  25. #include <dirent.h>
  26. #endif
  27. #include <errno.h>
  28. -#include <error.h>
  29. #ifdef HAVE_FCNTL_H
  30. #include <fcntl.h>
  31. #endif
  32. --- a/src/dav_fuse.c
  33. +++ b/src/dav_fuse.c
  34. @@ -47,6 +47,9 @@
  35. #ifdef HAVE_SYS_STAT_H
  36. #include <sys/stat.h>
  37. #endif
  38. +#ifdef HAVE_SYS_SELECT_H
  39. +#include <sys/select.h>
  40. +#endif
  41. #include "defaults.h"
  42. #include "mount_davfs.h"
  43. --- a/src/kernel_interface.c
  44. +++ b/src/kernel_interface.c
  45. @@ -19,8 +19,8 @@
  46. #include "config.h"
  47. +#include "compat.h"
  48. -#include <error.h>
  49. #ifdef HAVE_FCNTL_H
  50. #include <fcntl.h>
  51. #endif
  52. @@ -51,6 +51,9 @@
  53. #ifdef HAVE_SYS_STAT_H
  54. #include <sys/stat.h>
  55. #endif
  56. +#ifdef HAVE_SYS_TYPES_H
  57. +#include <sys/types.h>
  58. +#endif
  59. #include <sys/wait.h>
  60. #include "defaults.h"
  61. --- a/src/mount_davfs.c
  62. +++ b/src/mount_davfs.c
  63. @@ -19,10 +19,10 @@
  64. #include "config.h"
  65. +#include "compat.h"
  66. #include <ctype.h>
  67. #include <errno.h>
  68. -#include <error.h>
  69. #ifdef HAVE_FCNTL_H
  70. #include <fcntl.h>
  71. #endif
  72. --- a/src/umount_davfs.c
  73. +++ b/src/umount_davfs.c
  74. @@ -19,8 +19,8 @@
  75. #include "config.h"
  76. +#include "compat.h"
  77. -#include <error.h>
  78. #include <errno.h>
  79. #include <getopt.h>
  80. #ifdef HAVE_LIBINTL_H
  81. --- a/src/webdav.c
  82. +++ b/src/webdav.c
  83. @@ -19,9 +19,9 @@
  84. #include "config.h"
  85. +#include "compat.h"
  86. #include <errno.h>
  87. -#include <error.h>
  88. #ifdef HAVE_FCNTL_H
  89. #include <fcntl.h>
  90. #endif
  91. @@ -368,6 +368,7 @@ dav_init_webdav(const dav_args *args)
  92. error(EXIT_FAILURE, errno, _("socket library initialization failed"));
  93. if (args->neon_debug & ~NE_DBG_HTTPPLAIN) {
  94. +#ifdef HAVE_FOPENCOOKIE
  95. char *buf = malloc(log_bufsize);
  96. cookie_io_functions_t *log_func = malloc(sizeof(cookie_io_functions_t));
  97. if (!log_func) abort();
  98. @@ -380,6 +381,9 @@ dav_init_webdav(const dav_args *args)
  99. error(EXIT_FAILURE, errno,
  100. _("can't open stream to log neon-messages"));
  101. ne_debug_init(log_stream, args->neon_debug);
  102. +#else
  103. + error(EXIT_FAILURE, 0, "neon debugging unsupported");
  104. +#endif
  105. }
  106. session = ne_session_create(args->scheme, args->host, args->port);
  107. --- /dev/null
  108. +++ b/src/compat.h
  109. @@ -0,0 +1,64 @@
  110. +#ifndef _COMPAT_H
  111. +#define _COMPAT_H
  112. +
  113. +#ifndef _PATH_MOUNTED
  114. +# define _PATH_MOUNTED "/proc/mounts"
  115. +#endif
  116. +
  117. +#ifndef _PATH_MNTTAB
  118. +# define _PATH_MNTTAB "/etc/fstab"
  119. +#endif
  120. +
  121. +#ifdef HAVE_ERROR_H
  122. +# include <error.h>
  123. +#else
  124. +# include <stdio.h>
  125. +# include <stdarg.h>
  126. +# include <stdlib.h>
  127. +# include <string.h>
  128. +static void error_at_line(int status, int errnum, const char *filename,
  129. + unsigned int linenum, const char *format, ...)
  130. +{
  131. + va_list ap;
  132. +
  133. + fflush(stdout);
  134. +
  135. + if (filename != NULL)
  136. + fprintf(stderr, "%s:%u: ", filename, linenum);
  137. +
  138. + va_start(ap, format);
  139. + vfprintf(stderr, format, ap);
  140. + va_end(ap);
  141. +
  142. + if (errnum != 0)
  143. + fprintf(stderr, ": %s", strerror(errnum));
  144. +
  145. + fprintf(stderr, "\n");
  146. +
  147. + if (status != 0)
  148. + exit(status);
  149. +}
  150. +
  151. +#define error(status, errnum, format...) \
  152. + error_at_line(status, errnum, NULL, 0, format)
  153. +
  154. +#endif /* HAVE_ERROR_H */
  155. +
  156. +#ifndef HAVE_CANONICALIZE_FILE_NAME
  157. +#include <limits.h>
  158. +#include <string.h>
  159. +#include <stdlib.h>
  160. +static char * canonicalize_file_name(const char *path)
  161. +{
  162. + char buf[PATH_MAX] = { };
  163. +
  164. + snprintf(buf, sizeof(buf) - 1, "%s", path);
  165. +
  166. + if (!realpath(path, buf))
  167. + return NULL;
  168. +
  169. + return strdup(buf);
  170. +}
  171. +#endif
  172. +
  173. +#endif /* _COMPAT_H */