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