summaryrefslogtreecommitdiff
path: root/src
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
parentfbf51696ef1435cf358943c671ac55944ccec26c (diff)
downloadcurl-95719fbea6acf52d03b17de742f16be8f1f0ce70.tar.gz
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')
-rw-r--r--src/main.c10
-rw-r--r--src/xattr.c42
-rw-r--r--src/xattr.h25
3 files changed, 67 insertions, 10 deletions
diff --git a/src/main.c b/src/main.c
index 5394bac2a..6998f985a 100644
--- a/src/main.c
+++ b/src/main.c
@@ -5648,12 +5648,10 @@ operate(struct Configurable *config, int argc, argv_item_t argv[])
}
if(config->xattr && outs.filename) {
- char *url = NULL;
- curl_easy_getinfo(curl, CURLINFO_EFFECTIVE_URL, &url);
- int err = write_xattr( curl, outs.filename );
- if (err) {
- warnf( config, "Error setting extended attributes: %s\n", strerror(errno) );
- }
+ int err = write_xattr(curl, outs.filename );
+ if(err)
+ warnf( config, "Error setting extended attributes: %s\n",
+ strerror(errno) );
}
#ifdef HAVE_UTIME
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
diff --git a/src/xattr.h b/src/xattr.h
index 30673973c..df62066c8 100644
--- a/src/xattr.h
+++ b/src/xattr.h
@@ -1 +1,26 @@
+#ifndef __XATTR_H
+#define __XATTR_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.
+ *
+ ***************************************************************************/
int write_xattr( CURL *curl, const char *filename );
+
+#endif