RPM Community Forums

Mailing List Message of <rpm-cvs>

[CVS] RPM: xar/src/ xar.c

From: Anders F. Björklund <afb@rpm5.org>
Date: Fri 14 Sep 2007 - 14:37:06 CEST
Message-Id: <20070914123706.2DCAB34845C@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:   14-Sep-2007 14:37:06
  Branch: HEAD                             Handle: 2007091413370600

  Modified files:
    xar/src                 xar.c

  Log:
    list now has a verbose mode

  Summary:
    Revision    Changes     Path
    1.3         +29 -3      xar/src/xar.c
  ____________________________________________________________________________

  patch -p0 <<'@@ .'
  Index: xar/src/xar.c
  ============================================================================
  $ cvs diff -u -r1.2 -r1.3 xar.c
  --- xar/src/xar.c	30 Aug 2007 18:35:45 -0000	1.2
  +++ xar/src/xar.c	14 Sep 2007 12:37:06 -0000	1.3
  @@ -28,7 +28,7 @@
    */
   /*
    * 03-Apr-2005
  - * DRI: Rob Braun <bbraun@opendarwin.org>
  + * DRI: Rob Braun <bbraun@synack.net>
    */
   
   #include <stdlib.h>
  @@ -62,6 +62,7 @@
   static char *Rsize = NULL;
   
   static int Err = 0;
  +static int List = 0;
   static int Verbose = 0;
   static int Coalesce = 0;
   static int LinkSame = 0;
  @@ -83,8 +84,33 @@
   
   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);
  +}
  +
   static void print_file(xar_file_t f) {
  -	if( Verbose ) {
  +	if( List && (Verbose > 1) ) {
  +		char *path = xar_get_path(f);
  +		char *type = xar_get_type(f);
  +		char *size = xar_get_size(f);
  +		printf("%-20s %-10s %s\n", path, type, size);
  +		free(size);
  +		free(type);
  +		free(path);
  +
  +	} else if( List || Verbose ) {
   		char *path = xar_get_path(f);
   		printf("%s\n", path);
   		free(path);
  @@ -799,7 +825,7 @@
   				exit(1);
   			}
   			if( c == 't' )
  -				Verbose++;
  +				List = 1;
   			command = c;
   			break;
   		case 'f':
  @@ .
Received on Fri Sep 14 14:37:06 2007
Driven by Jeff Johnson and the RPM project team.
Hosted by OpenPKG and Ralf S. Engelschall.
Powered by FreeBSD and OpenPKG.