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