18 #define _RPMGI_INTERNAL
19 #define _RPMTS_INTERNAL
77 if (!(fts_info >= 1 && fts_info <= 14))
101 fd =
Fopen(fn, fmode);
103 if (fd == NULL ||
Ferror(fd)) {
105 if (fd != NULL) (void)
Fclose(fd);
171 if (gi->argv != NULL && gi->argv[gi->i] != NULL) {
172 gi->keyp = gi->argv[gi->i];
198 if (gi->argv != NULL && gi->argv[gi->i] != NULL)
202 fn = gi->argv[gi->i];
204 if (strchr(
"-+=", *fn) == NULL && !(gi->flags &
RPMGI_NOHEADER)) {
217 gi->argv[gi->i] = NULL;
221 gi->argv[gi->i] = fn;
265 if (strcmp(s,
".rpm"))
299 if (gi->ftsp != NULL)
300 while ((gi->fts =
Fts_read(gi->ftsp)) != NULL) {
301 if (gi->walkPathFilter)
302 rpmrc = (*gi->walkPathFilter) (gi);
321 if (gi->stash != NULL)
322 (void) (*gi->stash) (gi, gi->h);
337 for (se = s; *se; se++) {
345 for (se = s; *se; se++) {
374 while (argv[ac] != NULL)
385 while ((arg = *argv++) != NULL) {
415 fprintf(stderr,
"*** gi %p key %p[%d]\tmi %p\n", gi, gi->keyp, (
int)gi->keylen, gi->mi);
417 if (gi->argv != NULL)
418 for (av = (
const char **) gi->argv; *av != NULL; av++) {
428 if ((ae = strchr(a,
'=')) != NULL) {
441 fprintf(stderr,
"\tav %p[%d]: \"%s\" -> %s ~= \"%s\"\n", gi->argv, (
int)(av - gi->argv), *av,
tagName(tag), pat);
466 gi->hdrPath =
_free(gi->hdrPath);
472 if (gi->ftsp != NULL) {
477 if (gi->fd != NULL) {
497 if (_rpmgiPool == NULL) {
531 gi->argv =
xcalloc(1,
sizeof(*gi->argv));
536 gi->walkPathFilter = NULL;
556 fprintf(stderr,
"*** rpmgiNext(%p) tag %s\n", gi,
tagName(gi->tag));
561 gi->hdrPath =
_free(gi->hdrPath);
573 if (rpmrc !=
RPMRC_OK || gi->mi == NULL) {
581 if (gi->mi != NULL) {
587 gi->hdrPath =
rpmExpand(
"rpmdb h# ", hnum, NULL);
607 if (gi->mi != NULL) {
613 gi->hdrPath =
rpmExpand(
"rpmdb h# ", hnum, NULL);
627 const char * teTypeString = NULL;
633 if ((p =
rpmtsiNext(gi->tsi, teType)) != NULL) {
639 case TR_ADDED: teTypeString =
"+++";
break;
642 sprintf(hnum,
"%u", (
unsigned)gi->i);
643 gi->hdrPath =
rpmExpand(
"%s h# ", teTypeString, hnum, NULL);
656 const char * path =
rpmExpand(
"%{?_query_hdlist_path}", NULL);
657 if (path == NULL || *path ==
'\0') {
661 gi->fd =
rpmgiOpen(path,
"rm%{?_rpmgio}");
665 if (gi->fd != NULL) {
667 const char item[] =
"Header";
668 const char * msg = NULL;
680 sprintf(hnum,
"%u", (
unsigned)gi->i);
681 gi->hdrPath =
rpmExpand(
"hdlist h# ", hnum, NULL);
688 if (gi->fd != NULL) (void)
Fclose(gi->fd);
696 fprintf(stderr,
"*** gi %p\t%p[%d]: %s\n", gi, gi->argv, gi->i, gi->argv[gi->i]);
703 gi->hdrPath =
xstrdup(gi->argv[gi->i]);
706 if (gi->argv == NULL || gi->argv[0] == NULL)
710 gi->ftsp =
Fts_open((
char *
const *)gi->argv, gi->ftsOpts, NULL);
725 gi->hdrPath =
xstrdup(gi->fts->fts_path);
776 if (ts->suggests != NULL && ts->nsuggests > 0) {
778 for (i = 0; i < ts->nsuggests; i++) {
779 const char * str = ts->suggests[i];
786 ts->suggests[i] = NULL;
789 ts->suggests =
_free(ts->suggests);
800 xx = (*gi->tsOrder) (ts);
810 gi->hdrPath =
_free(gi->hdrPath);
823 return (gi != NULL ? gi->hdrPath : NULL);
829 return (gi != NULL ? gi->h : NULL);
836 return (gi != NULL ? gi->ts : NULL);
843 gi->ftsOpts = ftsOpts;