3 #include <rpmio_internal.h>
4 #define _RPMGI_INTERNAL
9 #include <rpmmessages.h>
14 static int gitag = RPMGI_FTSWALK;
15 static int ftsOpts = 0;
17 static const char * queryFormat = NULL;
19 static struct poptOption optionsTable[] = {
20 { "rpmgidebug", 'd', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_rpmgi_debug, -1,
21 N_("debug generalized iterator"), NULL},
23 { "rpmdb", '\0', POPT_ARG_VAL, &gitag, RPMGI_RPMDB,
24 N_("iterate rpmdb"), NULL },
25 { "hdlist", '\0', POPT_ARG_VAL, &gitag, RPMGI_HDLIST,
26 N_("iterate hdlist"), NULL },
27 { "arglist", '\0', POPT_ARG_VAL, &gitag, RPMGI_ARGLIST,
28 N_("iterate arglist"), NULL },
29 { "ftswalk", '\0', POPT_ARG_VAL, &gitag, RPMGI_FTSWALK,
30 N_("iterate fts(3) walk"), NULL },
32 { "qf", '\0', POPT_ARG_STRING, &queryFormat, 0,
33 N_("use the following query format"), "QUERYFORMAT" },
34 { "queryformat", '\0', POPT_ARG_STRING, &queryFormat, 0,
35 N_("use the following query format"), "QUERYFORMAT" },
37 { "comfollow", '\0', POPT_BIT_SET, &ftsOpts, FTS_COMFOLLOW,
38 N_("follow command line symlinks"), NULL },
39 { "logical", '\0', POPT_BIT_SET, &ftsOpts, FTS_LOGICAL,
40 N_("logical walk"), NULL },
41 { "nochdir", '\0', POPT_BIT_SET, &ftsOpts, FTS_NOCHDIR,
42 N_("don't change directories"), NULL },
43 { "nostat", '\0', POPT_BIT_SET, &ftsOpts, FTS_NOSTAT,
44 N_("don't get stat info"), NULL },
45 { "physical", '\0', POPT_BIT_SET, &ftsOpts, FTS_PHYSICAL,
46 N_("physical walk"), NULL },
47 { "seedot", '\0', POPT_BIT_SET, &ftsOpts, FTS_SEEDOT,
48 N_("return dot and dot-dot"), NULL },
49 { "xdev", '\0', POPT_BIT_SET, &ftsOpts, FTS_XDEV,
50 N_("don't cross devices"), NULL },
51 { "whiteout", '\0', POPT_BIT_SET, &ftsOpts, FTS_WHITEOUT,
52 N_("return whiteout information"), NULL },
54 { NULL, '\0', POPT_ARG_INCLUDE_TABLE, rpmcliAllPoptTable, 0,
55 N_("Common options for all rpm modes and executables:"),
64 main(int argc, char *const argv[])
74 optCon = rpmcliInit(argc, argv, optionsTable);
79 ftsOpts = (FTS_COMFOLLOW | FTS_LOGICAL | FTS_NOSTAT);
82 av = poptGetArgs(optCon);
83 gi = rpmgiNew(ts, gitag, av, ftsOpts);
84 (void) rpmgiSetQueryFormat(gi, queryFormat);
87 while ((arg = rpmgiNext(gi)) != NULL) {
88 fprintf(stderr, "%5d %s\n", ac, arg);
95 optCon = rpmcliFini(optCon);