~ubuntu-branches/ubuntu/wily/recoll/wily

« back to all changes in this revision

Viewing changes to utils/pxattr.cpp

  • Committer: Package Import Robot
  • Author(s): Kartik Mistry
  • Date: 2015-08-03 14:16:32 UTC
  • mfrom: (33.1.1 sid)
  • Revision ID: package-import@ubuntu.com-20150803141632-w5a1cr8ub2rkyvfe
Tags: 1.21.0-1
* New upstream release.
* debian/control:
  + Build-depend on python3-dev, python-dev, not python3-all-dev and
    python-all-dev. Thanks to Steve Langasek for patch. (Closes: #793636)
  + Added Build-depends on bison.

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
    \brief Portable External Attributes API
28
28
 */
29
29
 
 
30
// PXALINUX: platforms like kfreebsd which aren't linux but use the
 
31
// same xattr interface
30
32
#if defined(__gnu_linux__) || \
31
33
    (defined(__FreeBSD_kernel__)&&defined(__GLIBC__)&&!defined(__FreeBSD__)) ||\
32
 
    defined(__CYGWIN32__)
 
34
    defined(__CYGWIN__)
33
35
#define PXALINUX
34
36
#endif
35
37
 
36
 
// If the platform is not supported, let this file be empty instead of
 
38
// If the platform is not known yet, let this file be empty instead of
37
39
// breaking the compile, this will let the build work if the rest of
38
 
// the software is not actually calling us.
39
 
#if defined(__FreeBSD__) || defined(PXALINUX) || defined(__APPLE__)
 
40
// the software is not actually calling us. If it does call us, this
 
41
// will bring attention to the necessity of a port.
 
42
//
 
43
// If the platform is known not supporting extattrs (e.g.__OpenBSD__),
 
44
// just let the methods return errors (like they would on a non-xattr
 
45
// fs on e.g. linux)
 
46
#if defined(__FreeBSD__) || defined(PXALINUX) || defined(__APPLE__) \
 
47
    || defined(__OpenBSD__)
40
48
 
41
49
 
42
50
#ifndef TEST_PXATTR
52
60
#include <sys/xattr.h>
53
61
#elif defined(__APPLE__)
54
62
#include <sys/xattr.h>
 
63
#elif defined(__OpenBSD__)
55
64
#else
56
65
#error "Unknown system can't compile"
57
66
#endif
162
171
    } else {
163
172
        ret = fgetxattr(fd, name.c_str(), buf.buf, ret, 0, 0);
164
173
    }
 
174
#else
 
175
    errno = ENOTSUP;
165
176
#endif
166
177
 
167
178
    if (ret >= 0)
257
268
        ret = fsetxattr(fd, name.c_str(), value.c_str(), 
258
269
                        value.length(), 0, opts);
259
270
    }
 
271
#else
 
272
    errno = ENOTSUP;
260
273
#endif
261
274
    return ret >= 0;
262
275
}
302
315
    } else {
303
316
        ret = fremovexattr(fd, name.c_str(), 0);
304
317
    }
 
318
#else
 
319
    errno = ENOTSUP;
305
320
#endif
306
321
    return ret >= 0;
307
322
}
384
399
    } else {
385
400
        ret = flistxattr(fd, buf.buf, ret, 0);
386
401
    }
 
402
#else
 
403
    errno = ENOTSUP;
387
404
#endif
388
405
 
 
406
    if (ret < 0)
 
407
        return false;
 
408
 
389
409
    char *bufstart = buf.buf;
390
410
 
391
411
    // All systems return a 0-separated string list except FreeBSD