diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/Makefile | 39 | ||||
-rw-r--r-- | include/attributes.h | 184 | ||||
-rw-r--r-- | include/builddefs.in | 109 | ||||
-rw-r--r-- | include/buildmacros | 162 | ||||
-rw-r--r-- | include/buildrules | 104 | ||||
-rw-r--r-- | include/config.h.in | 42 | ||||
-rw-r--r-- | include/error_context.h | 53 | ||||
-rwxr-xr-x | include/install-sh | 363 | ||||
-rw-r--r-- | include/libattr.h | 46 | ||||
-rw-r--r-- | include/xattr.h | 63 |
10 files changed, 1165 insertions, 0 deletions
diff --git a/include/Makefile b/include/Makefile new file mode 100644 index 0000000..3068e56 --- /dev/null +++ b/include/Makefile @@ -0,0 +1,39 @@ +# +# Copyright (c) 2001-2002 Silicon Graphics, Inc. All Rights Reserved. +# Copyright (C) 2009 Andreas Gruenbacher <agruen@suse.de> +# +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +TOPDIR = .. +include $(TOPDIR)/include/builddefs + +INCDIR = attr +INST_HFILES = attributes.h xattr.h error_context.h libattr.h +HFILES = $(INST_HFILES) misc.h walk_tree.h +LSRCFILES = builddefs.in buildmacros buildrules config.h.in install-sh +LDIRT = $(INCDIR) + +default: $(INCDIR) + +$(INCDIR): + $(LN_S) . $@ + +include $(BUILDRULES) + +install-dev: default + $(INSTALL) -m 755 -d $(PKG_INC_DIR) + $(INSTALL) -m 644 $(INST_HFILES) $(PKG_INC_DIR) + +install install-lib: diff --git a/include/attributes.h b/include/attributes.h new file mode 100644 index 0000000..ba02025 --- /dev/null +++ b/include/attributes.h @@ -0,0 +1,184 @@ +/* + * Copyright (c) 2001-2002,2004 Silicon Graphics, Inc. + * All Rights Reserved. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 2.1 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ +#ifndef __ATTRIBUTES_H__ +#define __ATTRIBUTES_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * An almost-IRIX-compatible extended attributes API + * (the IRIX attribute "list" operation is missing, added ATTR_SECURE). + */ + +/* + * The maximum size (into the kernel or returned from the kernel) of an + * attribute value or the buffer used for an attr_list() call. Larger + * sizes will result in an E2BIG return code. + */ +#define ATTR_MAX_VALUELEN (64*1024) /* max length of a value */ + + +/* + * Flags that can be used with any of the simple attribute calls. + * All desired flags should be bit-wise OR'ed together. + */ +#define ATTR_DONTFOLLOW 0x0001 /* do not follow symlinks for a pathname */ +#define ATTR_ROOT 0x0002 /* use root namespace attributes in op */ +#define ATTR_TRUST 0x0004 /* tell server we can be trusted to properly + handle extended attributes */ +#define ATTR_SECURE 0x0008 /* use security namespace attributes in op */ + +/* + * Additional flags that can be used with the set() attribute call. + * All desired flags (from both lists) should be bit-wise OR'ed together. + */ +#define ATTR_CREATE 0x0010 /* pure create: fail if attr already exists */ +#define ATTR_REPLACE 0x0020 /* pure set: fail if attr does not exist */ + +/* + * Define how lists of attribute names are returned to the user from + * the attr_list() call. A large, 32bit aligned, buffer is passed in + * along with its size. We put an array of offsets at the top that each + * reference an attrlist_ent_t and pack the attrlist_ent_t's at the bottom. + */ +typedef struct attrlist { + int32_t al_count; /* number of entries in attrlist */ + int32_t al_more; /* T/F: more attrs (do call again) */ + int32_t al_offset[1]; /* byte offsets of attrs [var-sized] */ +} attrlist_t; + +/* + * Show the interesting info about one attribute. This is what the + * al_offset[i] entry points to. + */ +typedef struct attrlist_ent { /* data from attr_list() */ + u_int32_t a_valuelen; /* number bytes in value of attr */ + char a_name[1]; /* attr name (NULL terminated) */ +} attrlist_ent_t; + +/* + * Given a pointer to the (char*) buffer containing the attr_list() result, + * and an index, return a pointer to the indicated attribute in the buffer. + */ +#define ATTR_ENTRY(buffer, index) \ + ((attrlist_ent_t *) \ + &((char *)buffer)[ ((attrlist_t *)(buffer))->al_offset[index] ]) + +/* + * Implement a "cursor" for use in successive attr_list() calls. + * It provides a way to find the last attribute that was returned in the + * last attr_list() call so that we can get the next one without missing + * any. This should be bzero()ed before use and whenever it is desired to + * start over from the beginning of the attribute list. The only valid + * operation on a cursor is to bzero() it. + */ +typedef struct attrlist_cursor { + u_int32_t opaque[4]; /* an opaque cookie */ +} attrlist_cursor_t; + +/* + * Multi-attribute operation vector. + */ +typedef struct attr_multiop { + int32_t am_opcode; /* operation to perform (ATTR_OP_GET, etc.) */ + int32_t am_error; /* [out arg] result of this sub-op (an errno) */ + char *am_attrname; /* attribute name to work with */ + char *am_attrvalue; /* [in/out arg] attribute value (raw bytes) */ + int32_t am_length; /* [in/out arg] length of value */ + int32_t am_flags; /* flags (bit-wise OR of #defines above) */ +} attr_multiop_t; +#define ATTR_MAX_MULTIOPS 128 /* max number ops in an oplist array */ + +/* + * Valid values of am_opcode. + */ +#define ATTR_OP_GET 1 /* return the indicated attr's value */ +#define ATTR_OP_SET 2 /* set/create the indicated attr/value pair */ +#define ATTR_OP_REMOVE 3 /* remove the indicated attr */ + +/* + * Get the value of an attribute. + * Valuelength must be set to the maximum size of the value buffer, it will + * be set to the actual number of bytes used in the value buffer upon return. + * The return value is -1 on error (w/errno set appropriately), 0 on success. + */ +extern int attr_get (const char *__path, const char *__attrname, + char *__attrvalue, int *__valuelength, int __flags); +extern int attr_getf (int __fd, const char *__attrname, char *__attrvalue, + int *__valuelength, int __flags); + +/* + * Set the value of an attribute, creating the attribute if necessary. + * The return value is -1 on error (w/errno set appropriately), 0 on success. + */ +extern int attr_set (const char *__path, const char *__attrname, + const char *__attrvalue, const int __valuelength, + int __flags); +extern int attr_setf (int __fd, const char *__attrname, + const char *__attrvalue, const int __valuelength, + int __flags); + +/* + * Remove an attribute. + * The return value is -1 on error (w/errno set appropriately), 0 on success. + */ +extern int attr_remove (const char *__path, const char *__attrname, + int __flags); +extern int attr_removef (int __fd, const char *__attrname, int __flags); + +/* + * List the names and sizes of the values of all the attributes of an object. + * "Cursor" must be allocated and zeroed before the first call, it is used + * to maintain context between system calls if all the attribute names won't + * fit into the buffer on the first system call. + * The return value is -1 on error (w/errno set appropriately), 0 on success. + */ +int attr_list(const char *__path, char *__buffer, const int __buffersize, + int __flags, attrlist_cursor_t *__cursor); +int attr_listf(int __fd, char *__buffer, const int __buffersize, + int __flags, attrlist_cursor_t *__cursor); + +/* + * Operate on multiple attributes of the same object simultaneously. + * + * This call will save on system call overhead when many attributes are + * going to be operated on. + * + * The return value is -1 on error (w/errno set appropriately), 0 on success. + * Note that this call will not return -1 as a result of failure of any + * of the sub-operations, their return value is stored in each element + * of the operation array. This call will return -1 for a failure of the + * call as a whole, eg: if the pathname doesn't exist, or the fd is bad. + * + * The semantics and allowable values for the fields in a attr_multiop_t + * are the same as the semantics and allowable values for the arguments to + * the corresponding "simple" attribute interface. For example: the args + * to a ATTR_OP_GET are the same as the args to an attr_get() call. + */ +extern int attr_multi (const char *__path, attr_multiop_t *__oplist, + int __count, int __flags); +extern int attr_multif (int __fd, attr_multiop_t *__oplist, + int __count, int __flags); + +#ifdef __cplusplus +} +#endif + +#endif /* __ATTRIBUTES_H__ */ diff --git a/include/builddefs.in b/include/builddefs.in new file mode 100644 index 0000000..6df0f5a --- /dev/null +++ b/include/builddefs.in @@ -0,0 +1,109 @@ +# +# Copyright (c) 2002-2006 Silicon Graphics, Inc. All Rights Reserved. +# +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +# @configure_input@ +# + +ifndef _BUILDDEFS_INCLUDED_ +_BUILDDEFS_INCLUDED_ = 1 + +DEBUG = @debug_build@ +OPTIMIZER = @opt_build@ +MALLOCLIB = @malloc_lib@ +LOADERFLAGS = @LDFLAGS@ + +LIBATTR = $(TOPDIR)/libattr/libattr.la +LIBMISC = $(TOPDIR)/libmisc/libmisc.la + +prefix = @prefix@ +exec_prefix = @exec_prefix@ +top_builddir = @top_builddir@ +datarootdir = @datarootdir@ + +PKG_NAME = @pkg_name@ +PKG_USER = @pkg_user@ +PKG_GROUP = @pkg_group@ +PKG_RELEASE = @pkg_release@ +PKG_VERSION = @pkg_version@ +PKG_PLATFORM = @pkg_platform@ +PKG_DISTRIBUTION= @pkg_distribution@ +PKG_BIN_DIR = @bindir@ +PKG_SBIN_DIR = @sbindir@ +PKG_LIB_DIR = @libdir@@libdirsuffix@ +PKG_DEVLIB_DIR = @libexecdir@@libdirsuffix@ +PKG_INC_DIR = @includedir@/attr +PKG_MAN_DIR = @mandir@ +PKG_DOC_DIR = @datadir@/doc/@pkg_name@ +PKG_LOCALE_DIR = @datadir@/locale + +CC = @cc@ +AWK = @awk@ +SED = @sed@ +TAR = @tar@ +ZIP = @zip@ +MAKE = @make@ +ECHO = @echo@ +SORT = @sort@ +LN_S = @LN_S@ +LIBTOOL = @LIBTOOL@ +MAKEDEPEND = @makedepend@ + +MSGFMT = @msgfmt@ +MSGMERGE = @msgmerge@ +XGETTEXT = @xgettext@ + +RPM = @rpm@ +RPMBUILD = @rpmbuild@ +RPM_VERSION = @rpm_version@ + +ENABLE_SHARED = @enable_shared@ +ENABLE_GETTEXT = @enable_gettext@ + +HAVE_ZIPPED_MANPAGES = @have_zipped_manpages@ + +ifneq "$(findstring $(PKG_PLATFORM), linux gnu gnu/kfreebsd gnu/knetbsd)" "" +PCFLAGS = -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 +endif + +ifeq ($(PKG_PLATFORM),linux) +DEPENDFLAGS = -D__linux__ +endif +ifeq ($(PKG_PLATFORM),darwin) +DEPENDFLAGS = -D__APPLE__ +endif +ifeq ($(PKG_PLATFORM),irix) +DEPENDFLAGS = -D__sgi__ +endif +ifeq ($(PKG_PLATFORM),freebsd) +DEPENDFLAGS = -D__FreeBSD__ +endif + +GCFLAGS = $(OPTIMIZER) $(DEBUG) -funsigned-char -fno-strict-aliasing -Wall \ + -DVERSION=\"$(PKG_VERSION)\" -DLOCALEDIR=\"$(PKG_LOCALE_DIR)\" \ + -DPACKAGE=\"$(PKG_NAME)\" -I$(TOPDIR)/include + +# Global, Platform, Local CFLAGS +CFLAGS += $(GCFLAGS) $(PCFLAGS) $(LCFLAGS) + +include $(TOPDIR)/include/buildmacros + +endif + +# +# For targets that should always be rebuilt, +# define a target that is never up-to-date. +# Targets needing this should depend on $(_FORCE) +_FORCE = __force_build diff --git a/include/buildmacros b/include/buildmacros new file mode 100644 index 0000000..ab89182 --- /dev/null +++ b/include/buildmacros @@ -0,0 +1,162 @@ +# +# Copyright (c) 2002-2003 Silicon Graphics, Inc. All Rights Reserved. +# +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +BUILDRULES = $(TOPDIR)/include/buildrules + +# LCFLAGS, LLDFLAGS, LLDLIBS, LSRCFILES and LDIRT may be specified in +# user Makefiles. Note: LSRCFILES is anything other than Makefile, $(CFILES) +# $(CXXFILES), or $(HFILES) and is used to construct the manifest list +# during the "dist" phase (packaging). + +LDFLAGS += $(LOADERFLAGS) $(LLDFLAGS) +LTLDFLAGS += $(LOADERFLAGS) +LDLIBS = $(LLDLIBS) $(PLDLIBS) $(MALLOCLIB) + +MAKEOPTS = --no-print-directory +SRCFILES = Makefile $(HFILES) $(CFILES) $(LSRCFILES) $(LFILES) $(YFILES) + +DEPDIRT = dep dep.bak +MANDIRT = *.[1-9].gz +PODIRT = *.tmpo *.mo +CDIRT = $(OBJECTS) $(LTOBJECTS) $(LTCOMMAND) $(LTLIBRARY) +DIRT = $(LDIRT) $(DEPDIRT) $(MANDIRT) $(PODIRT) $(CDIRT) + +OBJECTS = $(ASFILES:.s=.o) \ + $(CFILES:.c=.o) \ + $(LFILES:.l=.o) \ + $(YFILES:%.y=%.tab.o) + +INSTALL = $(TOPDIR)/include/install-sh -o $(PKG_USER) -g $(PKG_GROUP) + +SHELL = /bin/sh +IMAGES_DIR = $(TOPDIR)/all-images +DIST_DIR = $(TOPDIR)/dist + +CCF = $(CC) $(CFLAGS) $(CPPFLAGS) +MAKEF = $(MAKE) $(MAKEOPTS) +CXXF = $(CXX) $(CXXFLAGS) + +# For libtool. +LIBNAME = $(basename $(LTLIBRARY)) +LTOBJECTS = $(OBJECTS:.o=.lo) +LTVERSION = $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) + +LTLINK = $(LIBTOOL) --mode=link $(CC) +LTEXEC = $(LIBTOOL) --mode=execute +LTINSTALL = $(LIBTOOL) --mode=install $(INSTALL) +LTCOMPILE = $(LIBTOOL) --mode=compile $(CCF) + +ifeq ($(ENABLE_SHARED),yes) +LTLDFLAGS += -rpath $(PKG_LIB_DIR) +LTLDFLAGS += -version-info $(LTVERSION) +endif + +ifeq ($(ENABLE_SHARED),yes) +INSTALL_LTLIB = \ + cd $(TOPDIR)/$(LIBNAME)/.libs; \ + ../$(INSTALL) -m 755 -d $(PKG_LIB_DIR); \ + ../$(INSTALL) -m 644 -T so_dot_version $(LIBNAME).lai $(PKG_LIB_DIR); \ + ../$(INSTALL) -T so_dot_current $(LIBNAME).lai $(PKG_LIB_DIR) +endif + +# Libtool thinks the static and shared libs should be in the same dir, so +# make the static lib appear in the place we chose as rpath (using the two +# symlinks below). +# Other things want the shared libs to appear in /usr/lib, else they'll +# link with the static libs there. So, another symlink to get the .so into +# /usr/lib. +ifeq ($(ENABLE_SHARED),yes) +INSTALL_LTLIB_DEV = \ + cd $(TOPDIR)/$(LIBNAME)/.libs; \ + ../$(INSTALL) -m 755 -d $(PKG_DEVLIB_DIR); \ + ../$(INSTALL) -m 644 -T old_lib $(LIBNAME).lai $(PKG_DEVLIB_DIR); \ + ../$(INSTALL) -m 644 $(LIBNAME).lai $(PKG_DEVLIB_DIR)/$(LIBNAME).la ; \ + ../$(INSTALL) -m 755 -d $(PKG_LIB_DIR); \ + ../$(INSTALL) -T so_base $(LIBNAME).lai $(PKG_LIB_DIR); \ + if test "x$(PKG_DEVLIB_DIR)" != "x$(PKG_LIB_DIR)" ; then \ + ../$(INSTALL) -S $(PKG_DEVLIB_DIR)/$(LIBNAME).a $(PKG_LIB_DIR)/$(LIBNAME).a; \ + ../$(INSTALL) -S $(PKG_DEVLIB_DIR)/$(LIBNAME).la $(PKG_LIB_DIR)/$(LIBNAME).la; \ + ../$(INSTALL) -S $(PKG_LIB_DIR)/$(LIBNAME).so $(PKG_DEVLIB_DIR)/$(LIBNAME).so; \ + fi +else +INSTALL_LTLIB_DEV = $(INSTALL_LTLIB_STATIC) +endif + +INSTALL_LTLIB_STATIC = \ + cd $(TOPDIR)/$(LIBNAME)/.libs; \ + ../$(INSTALL) -m 755 -d $(PKG_DEVLIB_DIR); \ + ../$(INSTALL) -m 644 -T old_lib $(LIBNAME).lai $(PKG_DEVLIB_DIR) + +INSTALL_MAN = \ + @for d in $(MAN_PAGES); do \ + first=true; \ + for m in `$(AWK) \ + '/^\.S[h|H] NAME/ {ok=1; next} ok {print; exit}' $$d \ + | $(SED) \ + -e 's/^\.Nm //' -e 's/,/ /g' -e 's/\\-.*//' \ + -e 's/\\\f[0-9]//g' -e 's/ / /g;q'`; \ + do \ + [ -z "$$m" -o "$$m" = "\\" ] && continue; \ + t=$(MAN_DEST)/$$m.$(MAN_SECTION); \ + if $$first; then \ + if $(HAVE_ZIPPED_MANPAGES); then \ + $(ZIP) -9 -c $$d > $$d.gz; _sfx=.gz; \ + fi; \ + u=$$m.$(MAN_SECTION)$$_sfx; \ + echo $(INSTALL) -m 644 $${d}$$_sfx $${t}$$_sfx;\ + $(INSTALL) -m 644 $${d}$$_sfx $${t}$$_sfx; \ + else \ + echo $(INSTALL) -S $$u $${t}$$_sfx; \ + $(INSTALL) -S $$u $${t}$$_sfx; \ + fi; \ + first=false; \ + done; \ + done + +ifeq ($(ENABLE_GETTEXT),yes) +INSTALL_LINGUAS = \ + @for l in $(LINGUAS) ""; do \ + if test -f "$$l.mo" ; then \ + ldir=$(PKG_LOCALE_DIR)/$$l/LC_MESSAGES; \ + $(INSTALL) -m 755 -d $$ldir; \ + $(INSTALL) -m 644 $$l.mo $$ldir/$(PKG_NAME).mo; \ + fi; \ + done +endif + +MAN_MAKERULE = \ + @for f in *.[12345678] ""; do \ + if test ! -z "$$f"; then \ + $(ZIP) --best -c < $$f > $$f.gz; \ + fi; \ + done + +DIST_MAKERULE = \ + $(MAKEF) -C build dist + +SOURCE_MAKERULE = \ + @test -z "$$DIR" && DIR="."; \ + for f in $(SRCFILES) ""; do \ + test -z "$$f" && break; \ + test -L "$$f" || $(ECHO) $$DIR/$$f; \ + done; \ + for d in `echo $(SUBDIRS)` ""; do \ + test -z "$$d" && break; \ + if test -d "$$d"; then \ + $(MAKEF) DIR=$$DIR/$$d -C $$d $@ || exit $$?; \ + fi; \ + done diff --git a/include/buildrules b/include/buildrules new file mode 100644 index 0000000..159d70c --- /dev/null +++ b/include/buildrules @@ -0,0 +1,104 @@ +# +# Copyright (c) 1999, 2001-2003 Silicon Graphics, Inc. All Rights Reserved. +# +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +ifndef _BUILDRULES_INCLUDED_ +_BUILDRULES_INCLUDED_ = 1 + +include $(TOPDIR)/include/builddefs + +clean clobber : $(addsuffix -clean,$(SUBDIRS)) + rm -f $(DIRT) + @rm -fr .libs + +%-clean: + $(MAKE) -C $* clean + +# Never blow away subdirs +ifdef SUBDIRS +.PRECIOUS: $(SUBDIRS) +.PHONY: $(SUBDIRS) + +$(SUBDIRS): + $(MAKE) -C $@ +endif + +# +# Standard targets +# + +ifdef LTCOMMAND +$(LTCOMMAND) : $(SUBDIRS) $(OBJECTS) $(LTDEPENDENCIES) + $(LTLINK) -o $@ $(LDFLAGS) $(OBJECTS) $(LDLIBS) +endif + +ifdef LTLIBRARY +$(LTLIBRARY) : $(SUBDIRS) $(LTOBJECTS) + $(LTLINK) $(LTLDFLAGS) -o $(LTLIBRARY) $(LTOBJECTS) $(LTLIBS) + +%.lo: %.c + $(LTCOMPILE) -c $< +endif + +ifdef POTHEAD +%.pot: $(XGETTEXTFILES) + $(XGETTEXT) --language=C --keyword=_ -o $@ $(XGETTEXTFILES) + +# Generate temp .po files, to check whether translations need updating. +# Not by default, due to gettext output differences between versions. +%.po: $(POTHEAD) +# $(MSGMERGE) -o $@.tmpo $@ $(POTHEAD) +# if ! diff $@.tmpo $@ >/dev/null; then echo "$@ dated, see $@.tmpo"; fi + +%.mo: %.po + $(MSGFMT) -o $@ $< +endif + +source : + $(SOURCE_MAKERULE) + +endif # _BUILDRULES_INCLUDED_ + +$(_FORCE): + +.PHONY : depend + +DEPENDSCRIPT := $(MAKEDEPEND) $(DEPENDFLAGS) -f - -- $(CFLAGS) -- $(CFILES) | \ + $(SED) -e 's,`pwd`,$(TOPDIR),g' \ + -e 's, */[^ ]*,,g' \ + -e '/^[^ ]*: *$$/d' \ + -e '/^ *$$/d' + +ifdef LTLIBRARY +DEPENDSCRIPT := $(DEPENDSCRIPT) | $(SED) -e 's,^\([^:]*\)\.o,\1.lo,' +endif + +depend : $(CFILES) $(HFILES) $(addsuffix -depend,$(SUBDIRS)) + $(DEPENDSCRIPT) > .dep + test -s .dep || rm -f .dep + +%-depend: + $(MAKE) -C $* depend + +# Include dep, but only if it exists +ifeq ($(shell test -f .dep && echo .dep), .dep) +include .dep +else +ifdef LTLIBRARY +$(LTOBJECTS): $(HFILES) +else +$(OBJECTS): $(HFILES) +endif +endif diff --git a/include/config.h.in b/include/config.h.in new file mode 100644 index 0000000..5695431 --- /dev/null +++ b/include/config.h.in @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2002 Silicon Graphics, Inc. All Rights Reserved. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * @configure_input@ + */ +#ifndef __CONFIG_H__ +#define __CONFIG_H__ + +/* Define if you want gettext (I18N) support */ +#undef ENABLE_GETTEXT + +/* Define to 1 if you have `alloca', as a function or macro. */ +#undef HAVE_ALLOCA + +/* Define to 1 if you have <alloca.h> and it should be used (not on Ultrix). + */ +#undef HAVE_ALLOCA_H + +#ifdef ENABLE_GETTEXT +# include <libintl.h> +# define _(x) gettext(x) +#else +# define _(x) (x) +# define textdomain(d) do { } while (0) +# define bindtextdomain(d,dir) do { } while (0) +#endif +#include <locale.h> + +#endif /* __CONFIG_H__ */ diff --git a/include/error_context.h b/include/error_context.h new file mode 100644 index 0000000..1117901 --- /dev/null +++ b/include/error_context.h @@ -0,0 +1,53 @@ +/* + Copyright (C) 2009 Andreas Gruenbacher <agruen@suse.de> + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 2.1 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef __ERROR_CONTEXT_T +#define __ERROR_CONTEXT_T + +#ifdef __cplusplus +extern "C" { +#endif + +struct error_context { + /* Process an error message */ + void (*error) (struct error_context *, const char *, ...); + + /* Quote a file name for including in an error message */ + const char *(*quote) (struct error_context *, const char *); + + /* Free a quoted name */ + void (*quote_free) (struct error_context *, const char *); +}; + +#ifdef ERROR_CONTEXT_MACROS +# define error(ctx, args...) do { \ + if ((ctx) && (ctx)->error) \ + (ctx)->error((ctx), args); \ + } while(0) +# define quote(ctx, name) \ + ( ((ctx) && (ctx)->quote) ? (ctx)->quote((ctx), (name)) : (name) ) +# define quote_free(ctx, name) do { \ + if ((ctx) && (ctx)->quote_free) \ + (ctx)->quote_free((ctx), (name)); \ + } while(0) +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* __ERROR_CONTEXT_T */ diff --git a/include/install-sh b/include/install-sh new file mode 100755 index 0000000..709e59d --- /dev/null +++ b/include/install-sh @@ -0,0 +1,363 @@ +#! /bin/sh +# +# Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved. +# +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +# This script emulates bsd install and also recognises +# two environment variables, with the following semantics :- +# +# $DIST_MANIFEST - if set, the name of the file to append manifest +# information in the following format: +# File : f mode owner group src target +# Directory: d mode owner group target +# Symlink : l linkval target +# +# $DIST_ROOT - if set, prepend to target +# +# The sematics of all combinations of these two variables +# are as follows: +# +# $DIST_MANIFEST? $DIST_ROOT? | Copy? Append Manifest? +# -----------------------------+-------------------------- +# not set not set | yes no +# not set set | yes no +# set not set | no yes +# set set | yes yes +# +_usage() { + echo "Usage: $prog [-o owner] [-g group] [-m mode] -d directory" + echo "or $prog [-D] [-o owner] [-g group] [-m mode] file directory/file" + echo "or $prog [-o owner] [-g group] [-m mode] file [file ...] directory" + echo "or $prog -S file target (creates \"target\" symlink)" + echo "or $prog -T lt_arg [-o owner] [-g group] [-m mode] libtool.lai directory" + echo "" + echo "The \$DIST_MANIFEST and \$DIST_ROOT environment variables affect the" + echo "behaviour of this command - see comments in the script." + echo "The -D flag is only available for the second usage, and causes" + echo "the target directory to be created before installing the file." + echo "" + exit 1 +} + +_chown () +{ + _st=255 + if [ $# -eq 3 ] ; then + chown $1:$2 $3 + _st=$? + if [ $_st -ne 0 ] ; then + if [ $REAL_UID != '0' ] ; then + if [ ! -f $DIST_ROOT/.chown.quiet ] ; then + echo '===============================================' + echo Ownership of files under ${DIST_ROOT:-/} + echo cannot be changed + echo '===============================================' + if [ -n "$DIST_ROOT" ] ; then + touch $DIST_ROOT/.chown.quiet + fi + fi + _st=0 + fi + fi + fi + + return $_st +} + + +_manifest () +{ + echo $* | sed -e 's/\/\//\//g' >>${DIST_MANIFEST:-/dev/null} +} + +prog=`basename $0` +HERE=`pwd` +dflag=false +Dflag=false +Sflag=false +Tflag=false +DIRMODE=755 +FILEMODE=644 +OWNER=`id -u` +GROUP=`id -g` +REAL_UID=$OWNER + +# default is to install and don't append manifest +INSTALL=true +MANIFEST=: + +[ -n "$DIST_MANIFEST" -a -z "$DIST_ROOT" ] && INSTALL=false +[ -n "$DIST_MANIFEST" ] && MANIFEST="_manifest" + +[ $# -eq 0 ] && _usage + +if $INSTALL +then + CP=cp; LN=ln; MKDIR=mkdir; CHMOD=chmod; CHOWN=_chown +else + CP=true; LN=true; MKDIR=true; CHMOD=true; CHOWN=true +fi + +[ -n "$DIST_ROOT" -a $REAL_UID -ne 0 ] && CHOWN=true + +while getopts "Dcm:d:S:o:g:T:" c $* +do + case $c in + c) + ;; + g) + GROUP=$OPTARG + ;; + o) + OWNER=$OPTARG + ;; + m) + DIRMODE=`expr $OPTARG` + FILEMODE=$DIRMODE + ;; + D) + Dflag=true + ;; + S) + symlink=$OPTARG + Sflag=true + ;; + d) + dir=$DIST_ROOT/$OPTARG + dflag=true + ;; + T) + lt_install=$OPTARG + Tflag=true + ;; + *) + _usage + ;; + esac +done + +shift `expr $OPTIND - 1` + +status=0 +if $dflag +then + # + # first usage + # + $MKDIR -p $dir + status=$? + if [ $status -eq 0 ] + then + $CHMOD $DIRMODE $dir + status=$? + fi + if [ $status -eq 0 ] + then + $CHOWN $OWNER $GROUP $dir + status=$? + fi + $MANIFEST d $DIRMODE $OWNER $GROUP ${dir#$DIST_ROOT} +elif $Sflag +then + # + # fourth usage (symlink) + # + if [ $# -ne 1 ] + then + _usage + else + target=$DIST_ROOT/$1 + fi + $LN -s -f $symlink $target + status=$? + $MANIFEST l $symlink ${target#$DIST_ROOT} +elif $Tflag +then + # + # -T (install libs built by libtool) + # + if [ $# -ne 2 ] + then + _usage + else + libtool_lai=$1 + # source the libtool variables + if [ ! -f $libtool_lai ] + then + echo "$prog: Unable to find libtool library file $libtool_lai" + exit 2 + fi + . ./$libtool_lai + target=$DIST_ROOT/$2 + fi + case $lt_install in + so_dot_version) + # Loop until we find libfoo.so.x.y.z, then break out. + for solib in $library_names + do + # does it have enough parts? libfoo.so.x.y.z == 5 + cnt=`echo "$solib" | sed -e 's/\./ /g' | wc -w` + if [ $cnt -eq 5 ] + then + install_name=$target/$solib + $CP $solib $install_name + status=$? + $MANIFEST f $FILEMODE $OWNER $GROUP $HERE/$solib ${install_name#$DIST_ROOT} + break + fi + done + ;; + + so_*) + case $lt_install in + so_dot_current) + # ln -s libfoo.so.x.y.z to libfoo.so.x + from_parts=5 # libfoo.so.x.y.z + to_parts=3 # libfoo.so.x + ;; + so_base) + # ln -s libfoo.so.x to libfoo.so + from_parts=3 # libfoo.so.x + to_parts=2 # libfoo.so + ;; + *) + echo "$prog: -T $lt_install invalid" + exit 2 + ;; + esac + + # Loop until we find the names, then break out. + for solib in $library_names + do + # does it have enough parts? + cnt=`echo "$solib" | sed -e 's/\./ /g' | wc -w` + if [ $cnt -eq $from_parts ] + then + from_name=$solib + elif [ $cnt -eq $to_parts ] + then + to_name=$solib + fi + + if [ -n "$from_name" ] && [ -n "$to_name" ] + then + install_name=$target/$to_name + $LN -s -f $from_name $install_name + status=$? + $MANIFEST l $from_name ${install_name#$DIST_ROOT} + break + fi + done + ;; + old_lib) + install_name=$target/$old_library + $CP $old_library $install_name + status=$? + $MANIFEST f $FILEMODE $OWNER $GROUP $HERE/$old_library ${install_name#$DIST_ROOT} + ;; + *) + echo "$prog: -T $lt_install invalid" + exit 2 + ;; + esac + + case $lt_install in + old_lib|so_dot_version) + if [ $status -eq 0 ] + then + $CHMOD $FILEMODE $install_name + $CHOWN $OWNER $GROUP $install_name + fi + ;; + esac + +else + list="" + dir="" + if [ $# -eq 2 ] + then + # + # second usage + # + f=$1 + dir=$DIST_ROOT/$2 + if $Dflag + then + mkdir -p `dirname $dir` + fi + $CP $f $dir + status=$? + if [ $status -eq 0 ] + then + if [ -f $dir/$f ] + then + $CHMOD $FILEMODE $dir/$f + status=$? + if [ $status -eq 0 ] + then + $CHOWN $OWNER $GROUP $dir/$f + status=$? + fi + $MANIFEST f $FILEMODE $OWNER $GROUP $HERE/$f ${dir#$DIST_ROOT}/$f + else + $CHMOD $FILEMODE $dir + status=$? + if [ $status -eq 0 ] + then + $CHOWN $OWNER $GROUP $dir + status=$? + fi + $MANIFEST f $FILEMODE $OWNER $GROUP $HERE/$dir ${dir#$DIST_ROOT} + fi + fi + else + # + # third usage + # + n=1 + while [ $# -gt 0 ] + do + if [ $# -gt 1 ] + then + list="$list $1" + else + dir=$DIST_ROOT/$1 + fi + shift + done + + # echo DIR=$dir list=\"$list\" + for f in $list + do + $CP $f $dir + status=$? + if [ $status -eq 0 ] + then + $CHMOD $FILEMODE $dir/$f + status=$? + if [ $status -eq 0 ] + then + $CHOWN $OWNER $GROUP $dir/$f + status=$? + fi + $MANIFEST f $FILEMODE $OWNER $GROUP $HERE/$f ${dir#$DIST_ROOT}/$f + fi + [ $status -ne 0 ] && break + done + fi +fi + +exit $status diff --git a/include/libattr.h b/include/libattr.h new file mode 100644 index 0000000..f57c431 --- /dev/null +++ b/include/libattr.h @@ -0,0 +1,46 @@ +/* + Copyright (C) 2009 Andreas Gruenbacher <agruen@suse.de> + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef __LIBATTR_H +#define __LIBATTR_H + +#ifdef __cplusplus +extern "C" { +#endif + +struct error_context; + +extern int attr_copy_file (const char *, const char *, + int (*) (const char *, struct error_context *), + struct error_context *); +extern int attr_copy_fd (const char *, int, const char *, int, + int (*) (const char *, struct error_context *), + struct error_context *); + +/* Keep this function for backwards compatibility. */ +extern int attr_copy_check_permissions(const char *, struct error_context *); + +#define ATTR_ACTION_SKIP 1 +#define ATTR_ACTION_PERMISSIONS 2 + +extern int attr_copy_action(const char *, struct error_context *); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/xattr.h b/include/xattr.h new file mode 100644 index 0000000..70a84be --- /dev/null +++ b/include/xattr.h @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2001-2002 Silicon Graphics, Inc. + * All Rights Reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + * License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/>. + * + */ +#ifndef __XATTR_H__ +#define __XATTR_H__ + +#include <features.h> + +#include <errno.h> +#ifndef ENOATTR +# define ENOATTR ENODATA /* No such attribute */ +#endif + +#define XATTR_CREATE 0x1 /* set value, fail if attr already exists */ +#define XATTR_REPLACE 0x2 /* set value, fail if attr does not exist */ + + +__BEGIN_DECLS + +extern int setxattr (const char *__path, const char *__name, + const void *__value, size_t __size, int __flags) __THROW; +extern int lsetxattr (const char *__path, const char *__name, + const void *__value, size_t __size, int __flags) __THROW; +extern int fsetxattr (int __filedes, const char *__name, + const void *__value, size_t __size, int __flags) __THROW; + +extern ssize_t getxattr (const char *__path, const char *__name, + void *__value, size_t __size) __THROW; +extern ssize_t lgetxattr (const char *__path, const char *__name, + void *__value, size_t __size) __THROW; +extern ssize_t fgetxattr (int __filedes, const char *__name, + void *__value, size_t __size) __THROW; + +extern ssize_t listxattr (const char *__path, char *__list, + size_t __size) __THROW; +extern ssize_t llistxattr (const char *__path, char *__list, + size_t __size) __THROW; +extern ssize_t flistxattr (int __filedes, char *__list, + size_t __size) __THROW; + +extern int removexattr (const char *__path, const char *__name) __THROW; +extern int lremovexattr (const char *__path, const char *__name) __THROW; +extern int fremovexattr (int __filedes, const char *__name) __THROW; + +__END_DECLS + +#endif /* __XATTR_H__ */ |