RPM Community Forums

Mailing List Message of <rpm-cvs>

[CVS] RPM: rpm-5_0: rpm/rpmio/ tdir.c tfts.c tget.c tglob.c thkp.c tma...

From: Jeff Johnson <jbj@rpm5.org>
Date: Mon 04 Feb 2008 - 21:39:34 CET
Message-Id: <20080204203934.6A483348458@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:   04-Feb-2008 21:39:34
  Branch: rpm-5_0                          Handle: 2008020420393300

  Added files:              (Branch: rpm-5_0)
    rpm/rpmio               tmire.c
  Modified files:           (Branch: rpm-5_0)
    rpm/rpmio               tdir.c tfts.c tget.c tglob.c thkp.c tmagic.c
                            tput.c

  Log:
    - jbj: add tmire.c, backport rest of EXTRA_PROGRAMS as well.

  Summary:
    Revision    Changes     Path
    2.6.2.1     +1  -1      rpm/rpmio/tdir.c
    2.10.2.1    +95 -37     rpm/rpmio/tfts.c
    1.10.2.1    +1  -1      rpm/rpmio/tget.c
    2.7.2.1     +1  -1      rpm/rpmio/tglob.c
    2.13.2.1    +3  -3      rpm/rpmio/thkp.c
    1.7.2.1     +1  -1      rpm/rpmio/tmagic.c
    1.1.2.1     +79 -0      rpm/rpmio/tmire.c
    1.5.2.1     +1  -1      rpm/rpmio/tput.c
  ____________________________________________________________________________

  patch -p0 <<'@@ .'
  Index: rpm/rpmio/tdir.c
  ============================================================================
  $ cvs diff -u -r2.6 -r2.6.2.1 tdir.c
  --- rpm/rpmio/tdir.c	18 Sep 2007 06:47:54 -0000	2.6
  +++ rpm/rpmio/tdir.c	4 Feb 2008 20:39:33 -0000	2.6.2.1
  @@ -2,7 +2,7 @@
   
   #include <rpmio_internal.h>
   #include <rpmmacro.h>
  -#include <rpmmessages.h>
  +#include <rpmcb.h>
   #include <popt.h>
   
   #include "debug.h"
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmio/tfts.c
  ============================================================================
  $ cvs diff -u -r2.10 -r2.10.2.1 tfts.c
  --- rpm/rpmio/tfts.c	18 Sep 2007 06:47:54 -0000	2.10
  +++ rpm/rpmio/tfts.c	4 Feb 2008 20:39:33 -0000	2.10.2.1
  @@ -3,32 +3,32 @@
   
   #include <rpmio_internal.h>
   #include <rpmmacro.h>
  -#include <rpmmessages.h>
  +#include <rpmcb.h>
  +#include <rpmmg.h>
  +#include <mire.h>
  +#include <argv.h>
   #include <popt.h>
   
   #include "debug.h"
   
  +static int mireMode = RPMMIRE_REGEX;
  +static int mireTag = 0;
  +static const char * mirePattern = NULL;
  +static miRE mire = NULL;
  +static int mireNExecs = 0;
  +static int mireNMatches = 0;
  +static int mireNFails = 0;
  +
  +static const char * mgFile = NULL;
  +static int mgFlags = 0;
  +static rpmmg mg = NULL;
  +static int mgNFiles = 0;
  +static int mgNMatches = 0;
  +static int mgNFails = 0;
  +
   /*@unchecked@*/
   static int _fts_debug = 0;
   
  -#if 0
  -#define HTTPSPATH	"https://localhost/rawhide/test/"
  -#define HTTPPATH	"http://localhost/rawhide/test/"
  -#else
  -#define HTTPSPATH	"https://localhost/rawhide/"
  -#define HTTPPATH	"http://localhost/rawhide/"
  -#endif
  -#define FTPPATH         "ftp://localhost/pub/rawhide/packages/test"
  -#define DIRPATH         "/var/ftp/pub/rawhide/packages/test"
  -#if 0
  -static char * httpspath = HTTPSPATH;
  -#endif
  -static char * httppath = HTTPPATH;
  -#if 0
  -static char * ftppath = FTPPATH;
  -static char * dirpath = DIRPATH;
  -#endif
  -
   static int ndirs = 0;
   static int nfiles = 0;
   
  @@ -60,6 +60,7 @@
   
   static int ftsPrint(FTS * ftsp, FTSENT * fts)
   {
  +    int xx;
   
       if (_fts_debug)
   	fprintf(stderr, "FTS_%s\t%*s %s\n", ftsInfoStr(fts->fts_info),
  @@ -74,6 +75,27 @@
   	break;
       case FTS_F:		/* regular file */
   	nfiles++;
  +	if (mire) {
  +	    mireNExecs++;
  +	    xx = mireRegexec(mire, fts->fts_accpath);
  +	    if (xx == 0) {
  +		fprintf(stdout, " mire: %s\n", fts->fts_accpath);
  +		mireNMatches++;
  +	    } else {
  +		mireNFails++;
  +	    }
  +	}
  +	if (mg) {
  +	    const char * s = rpmmgFile(mg, fts->fts_accpath);
  +	    mgNFiles++;
  +	    if (s != NULL) {
  +		fprintf(stdout, "magic: %s: %s\n", fts->fts_accpath, s);
  +		mgNMatches++;
  +	    } else {
  +		mgNFails++;
  +	    }
  +	    s = _free(s);
  +	}
   	break;
       case FTS_NS:	/* stat(2) failed */
       case FTS_DNR:	/* unreadable directory */
  @@ -96,28 +118,27 @@
   
   static int ftsOpts = 0;
   
  -static void ftsWalk(const char * path)
  +static int ftsWalk(ARGV_t av)
   {
  -    const char * ftsSet[2];
       FTS * ftsp;
       FTSENT * fts;
       int xx;
   
  -
  -    ftsSet[0] = path;
  -    ftsSet[1] = NULL;
  -
       ndirs = nfiles = 0;
  -    ftsp = Fts_open((char *const *)ftsSet, ftsOpts, NULL);
  +    ftsp = Fts_open((char *const *)av, ftsOpts, NULL);
       while((fts = Fts_read(ftsp)) != NULL)
   	xx = ftsPrint(ftsp, fts);
       xx = Fts_close(ftsp);
  -fprintf(stderr, "===== (%d/%d) dirs/files in %s\n", ndirs, nfiles, path);
   
  +fprintf(stderr, "===== (%d/%d) dirs/files in:\n", ndirs, nfiles);
  +    argvPrint(NULL, av, NULL);
  +
  +    return 0;
   }
   
   static struct poptOption optionsTable[] = {
  - { "ftsdebug", 'd', POPT_ARG_VAL,	&_fts_debug, -1,	NULL, NULL },
  + { "pattern", '\0', POPT_ARG_STRING,	&mirePattern, 0,	NULL, NULL },
  + { "magic", '\0', POPT_ARG_STRING,	&mgFile, 0,	NULL, NULL },
   
    { "comfollow", '\0', POPT_BIT_SET,	&ftsOpts, FTS_COMFOLLOW,
   	N_("follow command line symlinks"), NULL },
  @@ -136,12 +157,23 @@
    { "whiteout", '\0', POPT_BIT_SET,	&ftsOpts, FTS_WHITEOUT,
   	N_("return whiteout information"), NULL },
   
  + { "avdebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_av_debug, -1,
  +	N_("debug protocol data stream"), NULL},
  + { "davdebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_dav_debug, -1,
  +	N_("debug protocol data stream"), NULL},
  + { "ftsdebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_fts_debug, -1,
  +	N_("debug protocol data stream"), NULL},
    { "ftpdebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_ftp_debug, -1,
   	N_("debug protocol data stream"), NULL},
  + { "mgdebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_rpmmg_debug, -1,
  +	N_("debug protocol data stream"), NULL},
  + { "miredebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_mire_debug, -1,
  +	N_("debug protocol data stream"), NULL},
    { "rpmiodebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_rpmio_debug, -1,
   	N_("debug rpmio I/O"), NULL},
    { "urldebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_url_debug, -1,
   	N_("debug URL cache handling"), NULL},
  +
    { "verbose", 'v', 0, 0, 'v',				NULL, NULL },
     POPT_AUTOHELP
     POPT_TABLEEND
  @@ -151,9 +183,13 @@
   main(int argc, char *argv[])
   {
       poptContext optCon = poptGetContext(argv[0], argc, argv, optionsTable, 0);
  +    ARGV_t av = NULL;
  +    int ac = 0;
       int rc;
  +    int xx;
   
       while ((rc = poptGetNextOpt(optCon)) > 0) {
  +	const char * optArg = poptGetOptArg(optCon);
   	switch (rc) {
   	case 'v':
   	    rpmIncreaseVerbosity();
  @@ -161,24 +197,46 @@
   	default:
               /*@switchbreak@*/ break;
   	}
  +	optArg = _free(optArg);
       }
   
       if (ftsOpts == 0)
   	ftsOpts = (FTS_COMFOLLOW | FTS_LOGICAL | FTS_NOSTAT);
   
  +    if (_fts_debug) {
  +	rpmIncreaseVerbosity();
  +	rpmIncreaseVerbosity();
   _av_debug = -1;
  -_ftp_debug = -1;
   _dav_debug = 1;
  -#if 0
  -    ftsWalk(dirpath);
  -    ftsWalk(ftppath);
  -#endif
  -    ftsWalk(httppath);
  -#if 0
  -    ftsWalk(httpspath);
  -#endif
  +_ftp_debug = -1;
  +_rpmmg_debug = 1;
  +_mire_debug = 1;
  +    }
  +
  +    av = poptGetArgs(optCon);
  +    ac = argvCount(av);
  +    if (ac < 1) {
  +	poptPrintUsage(optCon, stderr, 0);
  +	goto exit;
  +    }
  +
  +    if (mirePattern) {
  +	mire = mireNew(mireMode, mireTag);
  +	if ((xx = mireRegcomp(mire, mirePattern)) != 0)
  +	    goto exit;;
  +    }
  +
  +    mg = rpmmgNew(mgFile, mgFlags);
  +
  +    ftsWalk(av);
  +
  +exit:
  +    mg = rpmmgFree(mg);
  +    mire = mireFree(mire);
   
   /*@i@*/ urlFreeCache();
   
  +    optCon = poptFreeContext(optCon);
  +
       return 0;
   }
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmio/tget.c
  ============================================================================
  $ cvs diff -u -r1.10 -r1.10.2.1 tget.c
  --- rpm/rpmio/tget.c	18 Sep 2007 06:47:54 -0000	1.10
  +++ rpm/rpmio/tget.c	4 Feb 2008 20:39:33 -0000	1.10.2.1
  @@ -2,7 +2,7 @@
   
   #include <rpmio_internal.h>
   #include <rpmmacro.h>
  -#include <rpmmessages.h>
  +#include <rpmcb.h>
   #include <popt.h>
   
   #include "debug.h"
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmio/tglob.c
  ============================================================================
  $ cvs diff -u -r2.7 -r2.7.2.1 tglob.c
  --- rpm/rpmio/tglob.c	18 Sep 2007 06:47:54 -0000	2.7
  +++ rpm/rpmio/tglob.c	4 Feb 2008 20:39:33 -0000	2.7.2.1
  @@ -2,7 +2,7 @@
   
   #include <rpmio_internal.h>
   #include <rpmmacro.h>
  -#include <rpmmessages.h>
  +#include <rpmcb.h>
   #include <popt.h>
   
   #include "debug.h"
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmio/thkp.c
  ============================================================================
  $ cvs diff -u -r2.13 -r2.13.2.1 thkp.c
  --- rpm/rpmio/thkp.c	20 Nov 2007 17:37:04 -0000	2.13
  +++ rpm/rpmio/thkp.c	4 Feb 2008 20:39:33 -0000	2.13.2.1
  @@ -2,7 +2,7 @@
   
   #include <rpmio_internal.h>
   #include <rpmmacro.h>
  -#include <rpmmessages.h>
  +#include <rpmcb.h>
   #include <popt.h>
   
   #include "debug.h"
  @@ -43,9 +43,9 @@
   static int readKeys(const char * uri)
   {
       unsigned int * kip;
  -    const byte * pkt;
  +    const uint8_t * pkt;
       size_t pktlen;
  -    byte keyid[8];
  +    uint8_t keyid[8];
       char fn[BUFSIZ];
       pgpDig dig;
       int rc;
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmio/tmagic.c
  ============================================================================
  $ cvs diff -u -r1.7 -r1.7.2.1 tmagic.c
  --- rpm/rpmio/tmagic.c	18 Sep 2007 06:47:54 -0000	1.7
  +++ rpm/rpmio/tmagic.c	4 Feb 2008 20:39:33 -0000	1.7.2.1
  @@ -5,8 +5,8 @@
   #include <rpmmg.h>
   
   #include <rpmio_internal.h>
  -#include <rpmmessages.h>
   #include <rpmmacro.h>
  +#include <rpmcb.h>
   #include <popt.h>
   
   #include "debug.h"
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmio/tmire.c
  ============================================================================
  $ cvs diff -u -r0 -r1.1.2.1 tmire.c
  --- /dev/null	2008-02-04 21:33:00 +0100
  +++ tmire.c	2008-02-04 21:39:34 +0100
  @@ -0,0 +1,79 @@
  +#include "system.h"
  +
  +#define _MIRE_INTERNAL
  +#include <rpmio.h>
  +#include <rpmcb.h>
  +#include <argv.h>
  +#include <mire.h>
  +#include <popt.h>
  +
  +#include "debug.h"
  +
  +static int _debug = 0;
  +
  +static struct poptOption optionsTable[] = {
  + { "debug", 'd', POPT_ARG_VAL,	&_debug, -1,		NULL, NULL },
  +  POPT_AUTOHELP
  +  POPT_TABLEEND
  +};
  +
  +int
  +main(int argc, char *argv[])
  +{
  +    poptContext optCon = poptGetContext(argv[0], argc, argv, optionsTable, 0);
  +    miRE mire = NULL;
  +    ARGV_t av = NULL;
  +    int ac = 0;
  +    int rc;
  +    int xx;
  +    int i;
  +
  +    while ((rc = poptGetNextOpt(optCon)) > 0) {
  +        const char * optArg = poptGetOptArg(optCon);
  +        optArg = _free(optArg);
  +	switch (rc) {
  +	case 'v':
  +	    rpmIncreaseVerbosity();
  +	    /*@switchbreak@*/ break;
  +	default:
  +	    poptPrintUsage(optCon, stderr, 0);
  +	    goto exit;
  +            /*@switchbreak@*/ break;
  +	}
  +    }
  +
  +    if (_debug) {
  +	rpmIncreaseVerbosity();
  +	rpmIncreaseVerbosity();
  +_mire_debug = 1;
  +    }
  +
  +    av = poptGetArgs(optCon);
  +    ac = argvCount(av);
  +    if (ac != 1) {
  +	poptPrintUsage(optCon, stderr, 0);
  +	goto exit;
  +    }
  +
  +    mire = mireNew(RPMMIRE_REGEX, 0);
  +    if ((xx = mireRegcomp(mire, argv[1])) != 0)
  +	goto exit;
  +    
  +    xx = argvFgets(&av, NULL);
  +    ac = argvCount(av);
  +
  +    for (i = 0; i < ac; i++) {
  +	xx = mireRegexec(mire, av[i]);
  +	if (xx == 0)
  +	    fprintf(stdout, "%s\n", av[i]);
  +    }
  +
  +exit:
  +    mire = mireFree(mire);
  +
  +    av = argvFree(av);
  +
  +    optCon = poptFreeContext(optCon);
  +
  +    return 0;
  +}
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmio/tput.c
  ============================================================================
  $ cvs diff -u -r1.5 -r1.5.2.1 tput.c
  --- rpm/rpmio/tput.c	18 Sep 2007 06:47:54 -0000	1.5
  +++ rpm/rpmio/tput.c	4 Feb 2008 20:39:33 -0000	1.5.2.1
  @@ -2,7 +2,7 @@
   
   #include <rpmio_internal.h>
   #include <rpmmacro.h>
  -#include <rpmmessages.h>
  +#include <rpmcb.h>
   #include <popt.h>
   
   #include "debug.h"
  @@ .
Received on Mon Feb 4 21:39:34 2008
Driven by Jeff Johnson and the RPM project team.
Hosted by OpenPKG and Ralf S. Engelschall.
Powered by FreeBSD and OpenPKG.