RPM Community Forums

Mailing List Message of <rpm-cvs>

[CVS] RPM: xar/ ChangeLog configure.ac xar/include/ config.h.in xar.h....

From: Anders F. Björklund <afb@rpm5.org>
Date: Fri 21 Sep 2007 - 13:55:43 CEST
Message-Id: <20070921115543.1A80834845D@rpm5.org>
  RPM Package Manager, CVS Repository
  http://rpm5.org/cvs/
  ____________________________________________________________________________

  Server: rpm5.org                         Name:   Anders F. Björklund
  Root:   /v/rpm/cvs                       Email:  afb@rpm5.org
  Module: xar                              Date:   21-Sep-2007 13:55:43
  Branch: HEAD                             Handle: 2007092112554200

  Added files:
    xar                     ChangeLog
    xar/lib                 strmode.h
  Modified files:
    xar                     configure.ac
    xar/include             config.h.in xar.h.in
    xar/lib                 archive.h err.c util.c
    xar/src                 xar.c

  Log:
    new features from upstream, which now has a ChangeLog too

  Summary:
    Revision    Changes     Path
    1.1         +10 -0      xar/ChangeLog
    1.9         +2  -1      xar/configure.ac
    1.2         +1  -0      xar/include/config.h.in
    1.3         +8  -1      xar/include/xar.h.in
    1.3         +1  -0      xar/lib/archive.h
    1.3         +5  -0      xar/lib/err.c
    1.1         +149 -0     xar/lib/strmode.h
    1.4         +126 -0     xar/lib/util.c
    1.7         +72 -103    xar/src/xar.c
  ____________________________________________________________________________

  patch -p0 <<'@@ .'
  Index: xar/ChangeLog
  ============================================================================
  $ cvs diff -u -r0 -r1.1 ChangeLog
  --- /dev/null	2007-09-21 13:55:00 +0200
  +++ ChangeLog	2007-09-21 13:55:42 +0200
  @@ -0,0 +1,10 @@
  +devel
  +	2007-09-19 Dave Leimbach leimy2k@gmail.com
  +	* xar/xar.c xar/xar.1: Added support for -j and -z as shortcuts for --compression=bzip2 or --compression=zlib respectively.
  +	2007-09-19 Rob Braun bbraun@synack.net
  +	* lib/zxar.c lib/bzxar.c: cleanup for more consistency between the two compression modules.  Patch contributed by Anders Björklund from the rpm5 project.
  +	2007-09-19 Rob Braun bbraun@synack.net
  +	* CHANGELOG: Added changelog
  +	* include/xar.h.in src/xar.c lib/util.c: moved helper functions for retrieving and formating file properties such as size, mode, mtime, etc. from src/xar.c to lib/util.c and exported them in xar.h.
  +	* lib/err.c lib/archive.h: Added the xar_t archive context to the error handler context to be able to retrieve archive level context within an error, such as archive level options, or being able to examine other files than the one the error occurred on.
  +	* lib/strmode.h lib/util.c config.h.in configure.ac: Import strmode(3) from freebsd to handle the formatting of file mode in xar_get_mode(), used for displaying file mode from xar -tvf.  configure will automatically detect whether to use the OS strmode(3) or the included copy.
  @@ .
  patch -p0 <<'@@ .'
  Index: xar/configure.ac
  ============================================================================
  $ cvs diff -u -r1.8 -r1.9 configure.ac
  --- xar/configure.ac	14 Sep 2007 12:36:02 -0000	1.8
  +++ xar/configure.ac	21 Sep 2007 11:55:42 -0000	1.9
  @@ -181,7 +181,7 @@
   )
   AC_SUBST([enable_autogen])
   
  -AC_TRY_COMPILE(,[#include <sys/types.h> #include <sys/acl.h>], [acl_t a], [AC_DEFINE([HAVE_SYS_ACL_H],[1], [define if you have sys/acl.h and it has a working acl_t type])])
  +AC_TRY_COMPILE([#include <sys/types.h> #include <sys/acl.h>], [acl_t a], [AC_DEFINE([HAVE_SYS_ACL_H],[1], [define if you have sys/acl.h and it has a working acl_t type])])
   AC_CHECK_HEADERS(ext2fs/ext2_fs.h sys/statfs.h sys/xattr.h sys/param.h sys/extattr.h libutil.h)
   AC_CHECK_FUNCS(lgetxattr)
   AC_CHECK_FUNCS(lsetxattr)
  @@ -194,6 +194,7 @@
   AC_CHECK_FUNCS(chflags)
   AC_CHECK_FUNCS(statvfs)
   AC_CHECK_FUNCS(statfs)
  +AC_CHECK_FUNCS(strmode)
   
   AC_CHECK_MEMBERS([struct statfs.f_fstypename],,,[#include <sys/types.h>
   #include <sys/param.h>
  @@ .
  patch -p0 <<'@@ .'
  Index: xar/include/config.h.in
  ============================================================================
  $ cvs diff -u -r1.1 -r1.2 config.h.in
  --- xar/include/config.h.in	30 May 2007 03:55:57 -0000	1.1
  +++ xar/include/config.h.in	21 Sep 2007 11:55:42 -0000	1.2
  @@ -21,6 +21,7 @@
   #undef HAVE_LIBBZ2
   #undef HAVE_LCHOWN
   #undef HAVE_LCHMOD
  +#undef HAVE_STRMODE
   #undef UID_STRING
   #undef UID_CAST
   #undef GID_STRING
  @@ .
  patch -p0 <<'@@ .'
  Index: xar/include/xar.h.in
  ============================================================================
  $ cvs diff -u -r1.2 -r1.3 xar.h.in
  --- xar/include/xar.h.in	30 Aug 2007 18:35:44 -0000	1.2
  +++ xar/include/xar.h.in	21 Sep 2007 11:55:42 -0000	1.3
  @@ -184,10 +184,17 @@
   
   uint8_t xar_signature_copy_signed_data(xar_signature_t sig, uint8_t **data, uint32_t *length, uint8_t **signed_data, uint32_t *signed_length);
   
  -
  +/* Helper functions - caller must free returned memory */
  +char *xar_get_size(xar_t x, xar_file_t f);
  +char *xar_get_type(xar_t x, xar_file_t f);
  +char *xar_get_mode(xar_t x, xar_file_t f);
  +char *xar_get_owner(xar_t x, xar_file_t f);
  +char *xar_get_group(xar_t x, xar_file_t f);
  +char *xar_get_mtime(xar_t x, xar_file_t f);
   
   /* These are for xar modules and should never be needed from a calling app */
   void xar_register_errhandler(xar_t x, err_handler callback, void *usrctx);
  +xar_t xar_err_get_archive(xar_errctx_t ctx);
   xar_file_t xar_err_get_file(xar_errctx_t ctx);
   const char *xar_err_get_string(xar_errctx_t ctx);
   int xar_err_get_errno(xar_errctx_t ctx);
  @@ .
  patch -p0 <<'@@ .'
  Index: xar/lib/archive.h
  ============================================================================
  $ cvs diff -u -r1.2 -r1.3 archive.h
  --- xar/lib/archive.h	19 Sep 2007 22:14:01 -0000	1.2
  +++ xar/lib/archive.h	21 Sep 2007 11:55:42 -0000	1.3
  @@ -51,6 +51,7 @@
   	int         saved_errno;
   	xar_file_t  file;
   	void       *usrctx;
  +	xar_t       x;
   };
   
   struct __xar_t {
  @@ .
  patch -p0 <<'@@ .'
  Index: xar/lib/err.c
  ============================================================================
  $ cvs diff -u -r1.2 -r1.3 err.c
  --- xar/lib/err.c	19 Sep 2007 22:14:01 -0000	1.2
  +++ xar/lib/err.c	21 Sep 2007 11:55:42 -0000	1.3
  @@ -40,11 +40,16 @@
   #define ECTX(x) ((struct errctx *)(x))
   
   void xar_register_errhandler(xar_t x, err_handler callback, void *usrctx) {
  +	ECTX(&XAR(x)->errctx)->x = x;
   	ECTX(&XAR(x)->errctx)->usrctx = usrctx;
   	XAR(x)->ercallback = callback;
   	return;
   }
   
  +xar_t xar_err_get_archive(xar_errctx_t ctx) {
  +	return ECTX(ctx)->x;
  +}
  +
   xar_file_t xar_err_get_file(xar_errctx_t ctx) {
   	return ECTX(ctx)->file;
   }
  @@ .
  patch -p0 <<'@@ .'
  Index: xar/lib/strmode.h
  ============================================================================
  $ cvs diff -u -r0 -r1.1 strmode.h
  --- /dev/null	2007-09-21 13:55:00 +0200
  +++ strmode.h	2007-09-21 13:55:42 +0200
  @@ -0,0 +1,149 @@
  +/*-
  + * Copyright (c) 1990, 1993
  + *	The Regents of the University of California.  All rights reserved.
  + *
  + * Redistribution and use in source and binary forms, with or without
  + * modification, are permitted provided that the following conditions
  + * are met:
  + * 1. Redistributions of source code must retain the above copyright
  + *    notice, this list of conditions and the following disclaimer.
  + * 2. Redistributions in binary form must reproduce the above copyright
  + *    notice, this list of conditions and the following disclaimer in the
  + *    documentation and/or other materials provided with the distribution.
  + * 4. Neither the name of the University nor the names of its contributors
  + *    may be used to endorse or promote products derived from this software
  + *    without specific prior written permission.
  + *
  + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  + * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  + * SUCH DAMAGE.
  + */
  +#ifndef HAVE_STRMODE
  +#if defined(LIBC_SCCS) && !defined(lint)
  +static char sccsid[] = "@(#)strmode.c	8.3 (Berkeley) 8/15/94";
  +#endif /* LIBC_SCCS and not lint */
  +
  +#include <sys/types.h>
  +#include <sys/stat.h>
  +#include <string.h>
  +
  +void
  +strmode(mode, p)
  +	mode_t mode;
  +	char *p;
  +{
  +	 /* print type */
  +	switch (mode & S_IFMT) {
  +	case S_IFDIR:			/* directory */
  +		*p++ = 'd';
  +		break;
  +	case S_IFCHR:			/* character special */
  +		*p++ = 'c';
  +		break;
  +	case S_IFBLK:			/* block special */
  +		*p++ = 'b';
  +		break;
  +	case S_IFREG:			/* regular */
  +		*p++ = '-';
  +		break;
  +	case S_IFLNK:			/* symbolic link */
  +		*p++ = 'l';
  +		break;
  +	case S_IFSOCK:			/* socket */
  +		*p++ = 's';
  +		break;
  +#ifdef S_IFIFO
  +	case S_IFIFO:			/* fifo */
  +		*p++ = 'p';
  +		break;
  +#endif
  +#ifdef S_IFWHT
  +	case S_IFWHT:			/* whiteout */
  +		*p++ = 'w';
  +		break;
  +#endif
  +	default:			/* unknown */
  +		*p++ = '?';
  +		break;
  +	}
  +	/* usr */
  +	if (mode & S_IRUSR)
  +		*p++ = 'r';
  +	else
  +		*p++ = '-';
  +	if (mode & S_IWUSR)
  +		*p++ = 'w';
  +	else
  +		*p++ = '-';
  +	switch (mode & (S_IXUSR | S_ISUID)) {
  +	case 0:
  +		*p++ = '-';
  +		break;
  +	case S_IXUSR:
  +		*p++ = 'x';
  +		break;
  +	case S_ISUID:
  +		*p++ = 'S';
  +		break;
  +	case S_IXUSR | S_ISUID:
  +		*p++ = 's';
  +		break;
  +	}
  +	/* group */
  +	if (mode & S_IRGRP)
  +		*p++ = 'r';
  +	else
  +		*p++ = '-';
  +	if (mode & S_IWGRP)
  +		*p++ = 'w';
  +	else
  +		*p++ = '-';
  +	switch (mode & (S_IXGRP | S_ISGID)) {
  +	case 0:
  +		*p++ = '-';
  +		break;
  +	case S_IXGRP:
  +		*p++ = 'x';
  +		break;
  +	case S_ISGID:
  +		*p++ = 'S';
  +		break;
  +	case S_IXGRP | S_ISGID:
  +		*p++ = 's';
  +		break;
  +	}
  +	/* other */
  +	if (mode & S_IROTH)
  +		*p++ = 'r';
  +	else
  +		*p++ = '-';
  +	if (mode & S_IWOTH)
  +		*p++ = 'w';
  +	else
  +		*p++ = '-';
  +	switch (mode & (S_IXOTH | S_ISVTX)) {
  +	case 0:
  +		*p++ = '-';
  +		break;
  +	case S_IXOTH:
  +		*p++ = 'x';
  +		break;
  +	case S_ISVTX:
  +		*p++ = 'T';
  +		break;
  +	case S_IXOTH | S_ISVTX:
  +		*p++ = 't';
  +		break;
  +	}
  +	*p++ = ' ';		/* will be a '+' if ACL's implemented */
  +	*p = '\0';
  +}
  +#endif /* HAVE_STRMODE */
  @@ .
  patch -p0 <<'@@ .'
  Index: xar/lib/util.c
  ============================================================================
  $ cvs diff -u -r1.3 -r1.4 util.c
  --- xar/lib/util.c	19 Sep 2007 22:14:01 -0000	1.3
  +++ xar/lib/util.c	21 Sep 2007 11:55:42 -0000	1.4
  @@ -168,3 +168,129 @@
   #endif
   	return;
   }
  +
  +
  +#ifndef HAVE_STRMODE
  +#include "strmode.h"
  +#endif
  +
  +char *xar_get_type(xar_t x, xar_file_t f) {
  +	const char *type = NULL;
  +	xar_prop_get(f, "type", &type);
  +	if( type == NULL )
  +		type = "unknown";
  +	return strdup(type);
  +}
  +
  +char *xar_get_size(xar_t x, xar_file_t f) {
  +	const char *size = NULL;
  +	const char *type = NULL;
  +
  +	xar_prop_get(f, "type", &type);
  +	if( type != NULL ) {
  +		if( strcmp(type, "hardlink") == 0 ) {
  +			const char *link = NULL;
  +			link = xar_attr_get(f, "type", "link");
  +			if( link ) {
  +				if( strcmp(link, "original") != 0 ) {
  +					xar_iter_t i;
  +					i = xar_iter_new();
  +					if( i ) {
  +						xar_file_t tmpf;
  +						for(tmpf = xar_file_first(x, i); tmpf; tmpf = xar_file_next(i)) {
  +							const char *id;
  +							id = xar_attr_get(tmpf, NULL, "id");
  +							if( !id ) continue;
  +							if( strcmp(id, link) == 0 ) {
  +								f = tmpf;
  +								break;
  +							}
  +						}
  +					}
  +					xar_iter_free(i);
  +				}
  +			}
  +		}
  +	}
  +	xar_prop_get(f, "data/size", &size);
  +	if( size == NULL )
  +		size = "0";
  +	return strdup(size);
  +}
  +
  +char *xar_get_mode(xar_t x, xar_file_t f) {
  +	const char *mode = NULL;
  +	const char *type = NULL;
  +	char *ret;
  +	mode_t m;
  +	xar_prop_get(f, "mode", &mode);
  +	if( mode == NULL )
  +		return  strdup("??????????");
  +	errno = 0;
  +	m = strtoll(mode, 0, 8);
  +	if( errno )
  +		return strdup("??????????");
  +
  +	xar_prop_get(f, "type", &type);
  +	if( type == NULL )
  +		return strdup("??????????");
  +		
  +	if( strcmp(type, "file") == 0 )
  +		m |= S_IFREG;
  +	else if( strcmp(type, "hardlink") == 0 )
  +		m |= S_IFREG;
  +	else if( strcmp(type, "directory") == 0 )
  +		m |= S_IFDIR;
  +	else if( strcmp(type, "symlink") == 0 )
  +		m |= S_IFLNK;
  +	else if( strcmp(type, "fifo") == 0 )
  +		m |= S_IFIFO;
  +	else if( strcmp(type, "character special") == 0 )
  +		m |= S_IFCHR;
  +	else if( strcmp(type, "block special") == 0 )
  +		m |= S_IFBLK;
  +	else if( strcmp(type, "socket") == 0 )
  +		m |= S_IFSOCK;
  +#ifdef S_IFWHT
  +	else if( strcmp(type, "whiteout") == 0 )
  +		m |= S_IFWHT;
  +#endif
  +
  +	ret = calloc(12,1);
  +	strmode(m, ret);
  +
  +	return ret;
  +}
  +
  +char *xar_get_owner(xar_t x, xar_file_t f) {
  +	const char *user = NULL;
  +
  +	xar_prop_get(f, "user", &user);
  +	if( !user )
  +		return strdup("unknown");
  +	return strdup(user);
  +}
  +
  +char *xar_get_group(xar_t x, xar_file_t f) {
  +	const char *group = NULL;
  +
  +	xar_prop_get(f, "group", &group);
  +	if( !group )
  +		return strdup("unknown");
  +	return strdup(group);
  +}
  +
  +char *xar_get_mtime(xar_t x, xar_file_t f) {
  +	const char *mtime = NULL;
  +	char *tmp;
  +	struct tm tm;
  +
  +	xar_prop_get(f, "mtime", &mtime);
  +	if( !mtime )
  +		mtime = "1970-01-01T00:00:00Z";
  +
  +	strptime(mtime, "%FT%T", &tm);
  +	tmp = calloc(128,1);
  +	strftime(tmp, 127, "%F %T", &tm);
  +	return tmp;
  +}
  @@ .
  patch -p0 <<'@@ .'
  Index: xar/src/xar.c
  ============================================================================
  $ cvs diff -u -r1.6 -r1.7 xar.c
  --- xar/src/xar.c	20 Sep 2007 10:25:45 -0000	1.6
  +++ xar/src/xar.c	21 Sep 2007 11:55:42 -0000	1.7
  @@ -85,105 +85,15 @@
   
   static int32_t err_callback(int32_t sev, int32_t err, xar_errctx_t ctx, void *usrctx);
   
  -char *xar_get_type(xar_file_t f) {
  -	const char *type = NULL;
  -	xar_prop_get(f, "type", &type);
  -	if( type == NULL )
  -		type = "unknown";
  -	return strdup(type);
  -}
  -
  -char *xar_get_size(xar_file_t f) {
  -	const char *size = NULL;
  -	xar_prop_get(f, "data/size", &size);
  -	if( size == NULL )
  -		size = "0";
  -	return strdup(size);
  -}
  -
  -char *xar_get_mode(xar_file_t f) {
  -	const char *mode = NULL;
  -	char *type = NULL;
  -	char *ret;
  -	mode_t m;
  -	xar_prop_get(f, "mode", &mode);
  -	if( mode == NULL )
  -		return strdup("??????????");
  -	errno = 0;
  -	m = strtoll(mode, 0, 8);
  -	if( errno )
  -		return strdup("??????????");
  -
  -	ret = calloc(11,1);
  -	memset(ret, '-', 10);
  -	ret[0] = '-';
  -	if( m & S_IXOTH ) ret[9] = 'x';
  -	if( m & S_IWOTH ) ret[8] = 'w';
  -	if( m & S_IROTH ) ret[7] = 'r';
  -	
  -	if( m & S_IXGRP ) ret[6] = 'x';
  -	if( m & S_IWGRP ) ret[5] = 'w';
  -	if( m & S_IRGRP ) ret[4] = 'r';
  -	if( m & S_ISGID ) ret[6] = 's';
  -
  -	if( m & S_IXUSR ) ret[3] = 'x';
  -	if( m & S_IWUSR ) ret[2] = 'w';
  -	if( m & S_IRUSR ) ret[1] = 'r';
  -	if( m & S_ISUID ) ret[3] = 's';
  -
  -	type = xar_get_type(f);
  -	if( !type )
  -		return ret;
  -
  -	if( strcmp(type, "directory") == 0 ) ret[0] = 'd';
  -	if( strcmp(type, "symlink") == 0 )   ret[0] = 'l';
  -	free(type);
  -
  -	return ret;
  -}
  -
  -char *xar_get_owner(xar_file_t f) {
  -	const char *user = NULL;
  -
  -	xar_prop_get(f, "user", &user);
  -	if( !user )
  -		return strdup("unknown");
  -	return strdup(user);
  -}
  -
  -char *xar_get_group(xar_file_t f) {
  -	const char *group = NULL;
  -
  -	xar_prop_get(f, "group", &group);
  -	if( !group )
  -		return strdup("unknown");
  -	return strdup(group);
  -}
  -
  -char *xar_get_mtime(xar_file_t f) {
  -	const char *mtime = NULL;
  -	char *tmp;
  -	struct tm tm;
  -
  -	xar_prop_get(f, "mtime", &mtime);
  -	if( !mtime )
  -		mtime = "1970-01-01T00:00:00Z";
  -
  -	strptime(mtime, "%FT%T", &tm);
  -	tmp = calloc(128,1);
  -	strftime(tmp, 127, "%F %T", &tm);
  -	return tmp;
  -}
  -
  -static void print_file(xar_file_t f) {
  +static void print_file(xar_t x, xar_file_t f) {
   	if( List && Verbose ) {
  +		char *size = xar_get_size(x, f);
   		char *path = xar_get_path(f);
  -		char *type = xar_get_type(f);
  -		char *size = xar_get_size(f);
  -		char *mode = xar_get_mode(f);
  -		char *user = xar_get_owner(f);
  -		char *group = xar_get_group(f);
  -		char *mtime = xar_get_mtime(f);
  +		char *type = xar_get_type(x, f);
  +		char *mode = xar_get_mode(x, f);
  +		char *user = xar_get_owner(x, f);
  +		char *group = xar_get_group(x, f);
  +		char *mtime = xar_get_mtime(x, f);
   		printf("%s %8s/%-8s %10s %s %s\n", mode, user, group, size, mtime, path);
   		free(size);
   		free(type);
  @@ -346,7 +256,7 @@
   		if( !f ) {
   			fprintf(stderr, "Error adding file %s\n", ent->fts_path);
   		} else {
  -			print_file(f);
  +			print_file(x, f);
   		}
   		if( !nocompress_match )
   			xar_opt_set(x, XAR_OPT_COMPRESSION, default_compression);
  @@ -487,7 +397,7 @@
   		
   		if( matched ) {
   			files_extracted++;
  -			print_file(f);
  +			print_file(x, f);
   			xar_extract(x, f);
   		}
   		free(path);
  @@ -540,6 +450,32 @@
   	xar_t x;
   	xar_iter_t i;
   	xar_file_t f;
  +	int argi = 0;
  +	struct lnode *list_files = NULL;
  +	struct lnode *list_tail = NULL;
  +	struct lnode *lnodei = NULL;
  +
  +	for(argi = 0; args[argi]; argi++) {
  +		struct lnode *tmp;
  +		int err;
  +		tmp = malloc(sizeof(struct lnode));
  +		tmp->str = strdup(args[argi]);
  +		tmp->next = NULL;
  +		err = regcomp(&tmp->reg, tmp->str, REG_NOSUB);
  +		if( err ) {
  +			char errstr[1024];
  +			regerror(err, &tmp->reg, errstr, sizeof(errstr));
  +			printf("Error with regular expression %s: %s\n", tmp->str, errstr);
  +			exit(1);
  +		}
  +		if( list_files == NULL ) {
  +			list_files = tmp;
  +			list_tail = tmp;
  +		} else {
  +			list_tail->next = tmp;
  +			list_tail = tmp;
  +		}
  +	}
   
   	x = xar_open(filename, READ);
   	if( !x ) {
  @@ -554,12 +490,40 @@
   	}
   
   	for(f = xar_file_first(x, i); f; f = xar_file_next(i)) {
  -		print_file(f);
  +		int matched = 0;
  +
  +		if( args[0] ) {
  +			char *path = xar_get_path(f);
  +			for(lnodei = list_files; lnodei != NULL; lnodei = lnodei->next) {
  +				int list_match = 1;
  +
  +				list_match = regexec(&lnodei->reg, path, 0, NULL, 0);
  +				if( !list_match ) {
  +					matched = 1;
  +					break;
  +				}
  +			}
  +			free(path);
  +		} else {
  +			matched = 1;
  +		}
  +
  +		if( matched )
  +			print_file(x, f);
   	}
   
   	xar_iter_free(i);
   	xar_close(x);
   
  +	for(lnodei = list_files; lnodei != NULL; ) {
  +		struct lnode *tmp;
  +		free(lnodei->str);
  +		regfree(&lnodei->reg);
  +		tmp = lnodei;
  +		lnodei = lnodei->next;
  +		free(tmp);
  +	}
  +
   	return Err;
   }
   
  @@ -621,9 +585,11 @@
   
   static int32_t err_callback(int32_t sev, int32_t err, xar_errctx_t ctx, void *usrctx) {
   	xar_file_t f;
  +	xar_t x;
   	const char *str;
   	int e;
   
  +	x = xar_err_get_archive(ctx);
   	f = xar_err_get_file(ctx);
   	str = xar_err_get_string(ctx);
   	e = xar_err_get_errno(ctx);
  @@ -637,7 +603,7 @@
   		break;
   	case XAR_SEVERITY_NORMAL:
   		if( (err = XAR_ERR_ARCHIVE_CREATION) && f )
  -    			print_file(f);
  +    			print_file(x, f);
   		break;
   	case XAR_SEVERITY_NONFATAL:
   	case XAR_SEVERITY_FATAL:
  @@ -720,6 +686,7 @@
   }
   
   int main(int argc, char *argv[]) {
  +	int ret;
   	char *filename = NULL;
   	char command = 0, c;
   	char **args;
  @@ -988,10 +955,12 @@
   			return extract(filename, arglen, args);
   		case 't':
   			arglen = argc - optind;
  -			args = malloc(sizeof(char*) * (arglen+1));
  +			args = calloc(sizeof(char*) * (arglen+1),1);
   			for( i = 0; i < arglen; i++ )
   				args[i] = strdup(argv[optind + i]);
  -			return list(filename, arglen, args);
  +			ret = list(filename, arglen, args);
  +			for( i = 0; i < arglen; i++ )
  +				free(args[i]);
   		case  6 :
   		case 's':
   			x = xar_open(filename, READ);
  @@ .
Received on Fri Sep 21 13:55:43 2007
Driven by Jeff Johnson and the RPM project team.
Hosted by OpenPKG and Ralf S. Engelschall.
Powered by FreeBSD and OpenPKG.