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. --- /dev/null
  33. +++ b/src/compat.h
  34. @@ -0,0 +1,64 @@
  35. +#ifndef _COMPAT_H
  36. +#define _COMPAT_H
  37. +
  38. +#ifndef _PATH_MOUNTED
  39. +# define _PATH_MOUNTED "/proc/mounts"
  40. +#endif
  41. +
  42. +#ifndef _PATH_MNTTAB
  43. +# define _PATH_MNTTAB "/etc/fstab"
  44. +#endif
  45. +
  46. +#ifdef HAVE_ERROR_H
  47. +# include <error.h>
  48. +#else
  49. +# include <stdio.h>
  50. +# include <stdarg.h>
  51. +# include <stdlib.h>
  52. +# include <string.h>
  53. +static void error_at_line(int status, int errnum, const char *filename,
  54. + unsigned int linenum, const char *format, ...)
  55. +{
  56. + va_list ap;
  57. +
  58. + fflush(stdout);
  59. +
  60. + if (filename != NULL)
  61. + fprintf(stderr, "%s:%u: ", filename, linenum);
  62. +
  63. + va_start(ap, format);
  64. + vfprintf(stderr, format, ap);
  65. + va_end(ap);
  66. +
  67. + if (errnum != 0)
  68. + fprintf(stderr, ": %s", strerror(errnum));
  69. +
  70. + fprintf(stderr, "\n");
  71. +
  72. + if (status != 0)
  73. + exit(status);
  74. +}
  75. +
  76. +#define error(status, errnum, format...) \
  77. + error_at_line(status, errnum, NULL, 0, format)
  78. +
  79. +#endif /* HAVE_ERROR_H */
  80. +
  81. +#ifndef HAVE_CANONICALIZE_FILE_NAME
  82. +#include <limits.h>
  83. +#include <string.h>
  84. +#include <stdlib.h>
  85. +static char * canonicalize_file_name(const char *path)
  86. +{
  87. + char buf[PATH_MAX] = { };
  88. +
  89. + snprintf(buf, sizeof(buf) - 1, "%s", path);
  90. +
  91. + if (!realpath(path, buf))
  92. + return NULL;
  93. +
  94. + return strdup(buf);
  95. +}
  96. +#endif
  97. +
  98. +#endif /* _COMPAT_H */
  99. --- a/src/dav_fuse.c
  100. +++ b/src/dav_fuse.c
  101. @@ -47,6 +47,9 @@
  102. #ifdef HAVE_SYS_STAT_H
  103. #include <sys/stat.h>
  104. #endif
  105. +#ifdef HAVE_SYS_SELECT_H
  106. +#include <sys/select.h>
  107. +#endif
  108. #include "defaults.h"
  109. #include "mount_davfs.h"
  110. --- a/src/kernel_interface.c
  111. +++ b/src/kernel_interface.c
  112. @@ -19,8 +19,8 @@
  113. #include "config.h"
  114. +#include "compat.h"
  115. -#include <error.h>
  116. #ifdef HAVE_FCNTL_H
  117. #include <fcntl.h>
  118. #endif
  119. @@ -51,6 +51,9 @@
  120. #ifdef HAVE_SYS_STAT_H
  121. #include <sys/stat.h>
  122. #endif
  123. +#ifdef HAVE_SYS_TYPES_H
  124. +#include <sys/types.h>
  125. +#endif
  126. #include <sys/wait.h>
  127. #include "defaults.h"
  128. --- a/src/mount_davfs.c
  129. +++ b/src/mount_davfs.c
  130. @@ -19,10 +19,10 @@
  131. #include "config.h"
  132. +#include "compat.h"
  133. #include <ctype.h>
  134. #include <errno.h>
  135. -#include <error.h>
  136. #ifdef HAVE_FCNTL_H
  137. #include <fcntl.h>
  138. #endif
  139. --- a/src/umount_davfs.c
  140. +++ b/src/umount_davfs.c
  141. @@ -19,8 +19,8 @@
  142. #include "config.h"
  143. +#include "compat.h"
  144. -#include <error.h>
  145. #include <errno.h>
  146. #include <getopt.h>
  147. #ifdef HAVE_LIBINTL_H
  148. --- a/src/webdav.c
  149. +++ b/src/webdav.c
  150. @@ -19,9 +19,9 @@
  151. #include "config.h"
  152. +#include "compat.h"
  153. #include <errno.h>
  154. -#include <error.h>
  155. #ifdef HAVE_FCNTL_H
  156. #include <fcntl.h>
  157. #endif
  158. @@ -368,6 +368,7 @@ dav_init_webdav(const dav_args *args)
  159. error(EXIT_FAILURE, errno, _("socket library initialization failed"));
  160. if (args->neon_debug & ~NE_DBG_HTTPPLAIN) {
  161. +#ifdef HAVE_FOPENCOOKIE
  162. char *buf = malloc(log_bufsize);
  163. cookie_io_functions_t *log_func = malloc(sizeof(cookie_io_functions_t));
  164. if (!log_func) abort();
  165. @@ -380,6 +381,9 @@ dav_init_webdav(const dav_args *args)
  166. error(EXIT_FAILURE, errno,
  167. _("can't open stream to log neon-messages"));
  168. ne_debug_init(log_stream, args->neon_debug);
  169. +#else
  170. + error(EXIT_FAILURE, 0, "neon debugging unsupported");
  171. +#endif
  172. }
  173. session = ne_session_create(args->scheme, args->host, args->port);