RPM Community Forums

Mailing List Message of <rpm-cvs>

[CVS] RPM: rpm/ CHANGES rpm/lib/ rpmrc.c rpm/rpmdb/ rpmdb.c rpm/rpmio/...

From: Jeff Johnson <jbj@rpm5.org>
Date: Sat 03 Nov 2007 - 14:19:24 CET
Message-Id: <20071103131924.0D2AA34847A@rpm5.org>
  RPM Package Manager, CVS Repository
  http://rpm5.org/cvs/
  ____________________________________________________________________________

  Server: rpm5.org                         Name:   Jeff Johnson
  Root:   /v/rpm/cvs                       Email:  jbj@rpm5.org
  Module: rpm                              Date:   03-Nov-2007 14:19:24
  Branch: HEAD                             Handle: 2007110313192201

  Modified files:
    rpm                     CHANGES
    rpm/lib                 rpmrc.c
    rpm/rpmdb               rpmdb.c
    rpm/rpmio               macro.c rpmmacro.h

  Log:
    - jbj: add a getter to retrieve macros with used and/or pattern filtering.
    - jbj: macro macro table/element internals opaque.

  Summary:
    Revision    Changes     Path
    1.1763      +2  -0      rpm/CHANGES
    2.213       +1  -3      rpm/lib/rpmrc.c
    1.197       +1  -1      rpm/rpmdb/rpmdb.c
    2.148       +62 -1      rpm/rpmio/macro.c
    2.41        +24 -4      rpm/rpmio/rpmmacro.h
  ____________________________________________________________________________

  patch -p0 <<'@@ .'
  Index: rpm/CHANGES
  ============================================================================
  $ cvs diff -u -r1.1762 -r1.1763 CHANGES
  --- rpm/CHANGES	2 Nov 2007 03:07:46 -0000	1.1762
  +++ rpm/CHANGES	3 Nov 2007 13:19:22 -0000	1.1763
  @@ -1,4 +1,6 @@
   4.5 -> 5.0:
  +    - jbj: add a getter to retrieve macros with used and/or pattern filtering.
  +    - jbj: macro macro table/element internals opaque.
       - jbj: fix --rebuilddb --root /path.
       - rse: fix linking of RPM against PCRE's POSIX API under --with-pcre
       - jbj: upgrade to F8 & fix rpm-python. i18n tags w hdr_subscript are b0rked.
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/lib/rpmrc.c
  ============================================================================
  $ cvs diff -u -r2.212 -r2.213 rpmrc.c
  --- rpm/lib/rpmrc.c	6 Oct 2007 21:33:48 -0000	2.212
  +++ rpm/lib/rpmrc.c	3 Nov 2007 13:19:23 -0000	2.213
  @@ -8,15 +8,13 @@
   #define __power_pc() 0
   #endif
   
  +#define _MIRE_INTERNAL
   #include <rpmio_internal.h> /* for rpmioSlurp() */
   #include <rpmcli.h>
   #include <rpmmacro.h>
   #include <rpmlua.h>
   #include <rpmds.h>
   
  -#define _MIRE_INTERNAL
  -#include <mire.h>
  -
   #include "misc.h"
   #include "debug.h"
   
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmdb/rpmdb.c
  ============================================================================
  $ cvs diff -u -r1.196 -r1.197 rpmdb.c
  --- rpm/rpmdb/rpmdb.c	2 Nov 2007 03:07:46 -0000	1.196
  +++ rpm/rpmdb/rpmdb.c	3 Nov 2007 13:19:23 -0000	1.197
  @@ -11,6 +11,7 @@
   #include <rpmio.h>
   #include <rpmpgp.h>
   #include <rpmurl.h>
  +#define	_MIRE_INTERNAL
   #include <rpmmacro.h>
   #include <rpmsq.h>
   #include <rpmtag.h>
  @@ -27,7 +28,6 @@
   #endif
   
   #define	_RPMDB_INTERNAL
  -#define	_MIRE_INTERNAL
   #include "rpmdb.h"
   #include "pkgio.h"
   #include "fprint.h"
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmio/macro.c
  ============================================================================
  $ cvs diff -u -r2.147 -r2.148 macro.c
  --- rpm/rpmio/macro.c	11 Oct 2007 13:04:28 -0000	2.147
  +++ rpm/rpmio/macro.c	3 Nov 2007 13:19:23 -0000	2.148
  @@ -68,6 +68,7 @@
   
   #endif
   
  +#define	_MACRO_INTERNAL
   #include <rpmmacro.h>
   
   #include "debug.h"
  @@ -201,7 +202,7 @@
       if (mc == NULL || mc->macroTable == NULL)
   	return;
   
  -    qsort(mc->macroTable, mc->firstFree, sizeof(*(mc->macroTable)),
  +    qsort(mc->macroTable, mc->firstFree, sizeof(mc->macroTable[0]),
   		compareMacroName);
   
       /* Empty pointers are now at end of table. Reset first free index. */
  @@ -213,6 +214,31 @@
       }
   }
   
  +static char * dupMacroEntry(MacroEntry me)
  +{
  +    char * t, * te;
  +    size_t nb;
  +
  +assert(me != NULL);
  +    nb = strlen(me->name) + sizeof("%") - 1;
  +    if (me->opts)
  +	nb += strlen(me->opts) + sizeof("()") - 1;
  +    if (me->body)
  +	nb += strlen(me->body) + sizeof("\t") - 1;
  +    nb++;
  +
  +    te = t = xmalloc(nb);
  +    *te = '\0';
  +    te = stpcpy( stpcpy(te, "%"), me->name);
  +    if (me->opts)
  +	te = stpcpy( stpcpy( stpcpy(te, "("), me->opts), ")");
  +    if (me->body)
  +	te = stpcpy( stpcpy(te, "\t"), me->body);
  +    *te = '\0';
  +
  +    return t;
  +}
  +
   void
   rpmDumpMacroTable(MacroContext mc, FILE * fp)
   {
  @@ -246,6 +272,41 @@
   		nactive, nempty);
   }
   
  +int
  +rpmGetMacroEntries(MacroContext mc, miRE mire, int used,
  +		const char *** avp)
  +{
  +    const char ** av;
  +    int ac;
  +    int i;
  +
  +    if (mc == NULL)
  +	mc = rpmGlobalMacroContext;
  +
  +    if (avp == NULL)
  +	return mc->firstFree;
  +
  +    av = xcalloc( (mc->firstFree+1), sizeof(mc->macroTable[0]));
  +    if (mc->macroTable != NULL)
  +    for (i = 0; i < mc->firstFree; i++) {
  +	MacroEntry me;
  +	me = mc->macroTable[i];
  +	if (used > 0 && me->used < used)
  +	    continue;
  +	if (used == 0 && me->used != 0)
  +	    continue;
  +#if !defined(DEBUG_MACROS)	/* XXX preserve standalone build */
  +	if (mireRegexec(mire, me->name))
  +	    continue;
  +#endif
  +	av[ac++] = dupMacroEntry(me);
  +    }
  +    av[ac] = NULL;
  +    *avp = av = xrealloc(av, (ac+1) * sizeof(*av));
  +    
  +    return ac;
  +}
  +
   /**
    * Find entry in macro table.
    * @param mc		macro context
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmio/rpmmacro.h
  ============================================================================
  $ cvs diff -u -r2.40 -r2.41 rpmmacro.h
  --- rpm/rpmio/rpmmacro.h	6 Oct 2007 19:40:23 -0000	2.40
  +++ rpm/rpmio/rpmmacro.h	3 Nov 2007 13:19:23 -0000	2.41
  @@ -1,12 +1,17 @@
   #ifndef _H_MACRO_
   #define	_H_MACRO_
   
  +#include <mire.h>
  +
   /** \ingroup rpmio
    * \file rpmio/rpmmacro.h
    */
  +typedef /*@abstract@*/ struct MacroEntry_s * MacroEntry;
  +typedef /*@abstract@*/ struct MacroContext_s * MacroContext;
   
  +#if defined(_MACRO_INTERNAL)
   /*! The structure used to store a macro. */
  -typedef /*@abstract@*/ struct MacroEntry_s {
  +struct MacroEntry_s {
       struct MacroEntry_s *prev;	/*!< Macro entry stack. */
       const char *name;		/*!< Macro name. */
       const char *opts;		/*!< Macro parameters (a la getopt) */
  @@ -14,15 +19,16 @@
       int	used;			/*!< No. of expansions. */
       short level;		/*!< Scoping level. */
       unsigned short flags;	/*!< Flags. */
  -} * MacroEntry;
  +};
   
   /*! The structure used to store the set of macros in a context. */
  -typedef /*@abstract@*/ struct MacroContext_s {
  +struct MacroContext_s {
   /*@owned@*//*@null@*/
       MacroEntry *macroTable;	/*!< Macro entry table for context. */
       int	macrosAllocated;	/*!< No. of allocated macros. */
       int	firstFree;		/*!< No. of macros. */
  -} * MacroContext;
  +};
  +#endif
   
   /*@-redecl@*/
   /*@checked@*/
  @@ -67,6 +73,20 @@
   	/*@modifies *fp, fileSystem @*/;
   
   /**
  + * Return macro entries as string array.
  + * @param mc		macro context (NULL uses global context)
  + * @param mire		pattern to match (NULL disables)
  + * @param used		macro usage (<0 all, =0 unused, >=1 used count)
  + * @retval *avp		macro definitions
  + * @return		no. of entries
  + */
  +int
  +rpmGetMacroEntries(/*@null@*/ MacroContext mc, /*@null@*/ miRE mire,
  +		int used, /*@null@*/ const char *** avp)
  +	/*@globals rpmGlobalMacroContext @*/
  +	/*@modifies *avp @*/;
  +
  +/**
    * Return URL path(s) from a (URL prefixed) pattern glob.
    * @param patterns	glob pattern
    * @retval *argcPtr	no. of paths
  @@ .
Received on Sat Nov 3 14:19:24 2007
Driven by Jeff Johnson and the RPM project team.
Hosted by OpenPKG and Ralf S. Engelschall.
Powered by FreeBSD and OpenPKG.