aboutsummaryrefslogtreecommitdiff
path: root/src/xattr.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2010-11-05 14:07:38 +0100
committerDaniel Stenberg <daniel@haxx.se>2010-11-05 14:07:38 +0100
commit95719fbea6acf52d03b17de742f16be8f1f0ce70 (patch)
tree00092046ba3080c7813dff31bd6d3155a83fe326 /src/xattr.c
parentfbf51696ef1435cf358943c671ac55944ccec26c (diff)
xattr: add configure check and #ifdefs
setxattr is a glibc call to set extended attributes, so configure now checks for it and the code is adapted to only build when the functionality is present.
Diffstat (limited to 'src/xattr.c')
-rw-r--r--src/xattr.c42
1 files changed, 38 insertions, 4 deletions
diff --git a/src/xattr.c b/src/xattr.c
index fbc09c207..1047c8a63 100644
--- a/src/xattr.c
+++ b/src/xattr.c
@@ -1,9 +1,35 @@
-#include <sys/types.h>
-#include <sys/xattr.h> /* include header from libc, not from libattr */
-#include <string.h>
+/***************************************************************************
+ * _ _ ____ _
+ * Project ___| | | | _ \| |
+ * / __| | | | |_) | |
+ * | (__| |_| | _ <| |___
+ * \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) 2010, Daniel Stenberg, <daniel@haxx.se>, et al.
+ *
+ * This software is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at http://curl.haxx.se/docs/copyright.html.
+ *
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
+ * copies of the Software, and permit persons to whom the Software is
+ * furnished to do so, under the terms of the COPYING file.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ***************************************************************************/
+
+/* client-local setup.h */
+#include "setup.h"
#include <curl/curl.h>
#include "xattr.h"
+#ifdef HAVE_SETXATTR
+#include <sys/types.h>
+#include <string.h>
+#include <sys/xattr.h> /* include header from libc, not from libattr */
+
/* mapping table of curl metadata to extended attribute names */
static struct xattr_mapping {
char *attr; /* name of the xattr */
@@ -20,7 +46,7 @@ static struct xattr_mapping {
/* store metadata from the curl request alongside the downloaded
* file using extended attributes
*/
-int write_xattr( CURL *curl, const char *filename )
+int write_xattr(CURL *curl, const char *filename)
{
int i = 0;
int err = 0;
@@ -35,3 +61,11 @@ int write_xattr( CURL *curl, const char *filename )
}
return err;
}
+#else
+int write_xattr(CURL *curl, const char *filename)
+{
+ (void)curl;
+ (void)filename;
+ return 0;
+}
+#endif