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.

120 lines
2.4 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 iconv.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 iconv.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])
  9. # Checks for typedefs, structures, and compiler characteristics.
  10. AC_C_CONST
  11. --- a/src/cache.c
  12. +++ b/src/cache.c
  13. @@ -19,12 +19,12 @@
  14. #include "config.h"
  15. +#include "compat.h"
  16. #ifdef HAVE_DIRENT_H
  17. #include <dirent.h>
  18. #endif
  19. #include <errno.h>
  20. -#include <error.h>
  21. #ifdef HAVE_FCNTL_H
  22. #include <fcntl.h>
  23. #endif
  24. --- /dev/null
  25. +++ b/src/compat.h
  26. @@ -0,0 +1,39 @@
  27. +#ifndef _COMPAT_H
  28. +#define _COMPAT_H
  29. +
  30. +#ifdef HAVE_ERROR_H
  31. +# include <error.h>
  32. +#else
  33. +# include <stdio.h>
  34. +# include <stdarg.h>
  35. +# include <stdlib.h>
  36. +# include <string.h>
  37. +static void error_at_line(int status, int errnum, const char *filename,
  38. + unsigned int linenum, const char *format, ...)
  39. +{
  40. + va_list ap;
  41. +
  42. + fflush(stdout);
  43. +
  44. + if (filename != NULL)
  45. + fprintf(stderr, "%s:%u: ", filename, linenum);
  46. +
  47. + va_start(ap, format);
  48. + vfprintf(stderr, format, ap);
  49. + va_end(ap);
  50. +
  51. + if (errnum != 0)
  52. + fprintf(stderr, ": %s", strerror(errnum));
  53. +
  54. + fprintf(stderr, "\n");
  55. +
  56. + if (status != 0)
  57. + exit(status);
  58. +}
  59. +
  60. +#define error(status, errnum, format...) \
  61. + error_at_line(status, errnum, NULL, 0, format)
  62. +
  63. +#endif /* HAVE_ERROR_H */
  64. +
  65. +#endif /* _COMPAT_H */
  66. --- a/src/kernel_interface.c
  67. +++ b/src/kernel_interface.c
  68. @@ -19,8 +19,8 @@
  69. #include "config.h"
  70. +#include "compat.h"
  71. -#include <error.h>
  72. #ifdef HAVE_FCNTL_H
  73. #include <fcntl.h>
  74. #endif
  75. --- a/src/mount_davfs.c
  76. +++ b/src/mount_davfs.c
  77. @@ -19,10 +19,10 @@
  78. #include "config.h"
  79. +#include "compat.h"
  80. #include <ctype.h>
  81. #include <errno.h>
  82. -#include <error.h>
  83. #ifdef HAVE_FCNTL_H
  84. #include <fcntl.h>
  85. #endif
  86. --- a/src/umount_davfs.c
  87. +++ b/src/umount_davfs.c
  88. @@ -19,8 +19,8 @@
  89. #include "config.h"
  90. +#include "compat.h"
  91. -#include <error.h>
  92. #include <errno.h>
  93. #include <getopt.h>
  94. #ifdef HAVE_LIBINTL_H
  95. --- a/src/webdav.c
  96. +++ b/src/webdav.c
  97. @@ -19,9 +19,9 @@
  98. #include "config.h"
  99. +#include "compat.h"
  100. #include <errno.h>
  101. -#include <error.h>
  102. #ifdef HAVE_FCNTL_H
  103. #include <fcntl.h>
  104. #endif