From 95719fbea6acf52d03b17de742f16be8f1f0ce70 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 5 Nov 2010 14:07:38 +0100 Subject: 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. --- src/main.c | 10 ++++------ src/xattr.c | 42 ++++++++++++++++++++++++++++++++++++++---- src/xattr.h | 25 +++++++++++++++++++++++++ 3 files changed, 67 insertions(+), 10 deletions(-) (limited to 'src') 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 -#include /* include header from libc, not from libattr */ -#include +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 2010, Daniel Stenberg, , 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 #include "xattr.h" +#ifdef HAVE_SETXATTR +#include +#include +#include /* 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, , 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 -- cgit v1.2.3