int main(int argc, char *argv[]) { poptContext optCon = rpmioInit(argc, argv, optionsTable); rpmtget tget = xcalloc(1, sizeof(*tget)); ARGV_t av = NULL; int ac; int rc = 0; int xx; if (__debug) { _av_debug = -1; _dav_debug = -1; _ftp_debug = -1; _url_debug = -1; _rpmio_debug = -1; } av = poptGetArgs(optCon); ac = argvCount(av); if (ac < 1) { poptPrintUsage(optCon, stderr, 0); goto exit; } tget->pattern = hrefpat; xx = mireAppend(RPMMIRE_PCRE, 0, tget->pattern, NULL, &tget->mires, &tget->nmires); while (rc == 0 && (tget->uri = *av++) != NULL) rc = readFile(tget); tget->mires = mireFreeAll(tget->mires, tget->nmires); tget->nmires = 0; exit: optCon = rpmioFini(optCon); return rc; }
static int printGlob(const char * path) { rpmop op = memset(alloca(sizeof(*op)), 0, sizeof(*op)); glob_t gl = { .gl_pathc = 0, .gl_pathv = NULL, .gl_offs = 0 }; int rc; int xx; fprintf(stderr, "===== %s\n", path); xx = rpmswEnter(op, 0); gl.gl_pathc = 0; gl.gl_pathv = NULL; gl.gl_offs = 0; rc = Glob(path, 0, my_Glob_error, &gl); if (rc != 0) { fprintf(stderr, "*** Glob rc %d\n", rc); } else if (rpmIsVerbose()) { int i; for (i = 0; i < (int)gl.gl_pathc; i++) fprintf(stderr, "%5d %s\n", i, gl.gl_pathv[i]); } Globfree(&gl); xx = rpmswExit(op, 0); if (_rpmsw_stats) rpmswPrint("glob:", op, NULL); return rc; } static struct poptOption optionsTable[] = { { "debug", 'd', POPT_ARG_VAL, &__debug, -1, NULL, NULL }, { NULL, '\0', POPT_ARG_INCLUDE_TABLE, rpmioAllPoptTable, 0, N_("Common options for all rpmio executables:"), NULL }, POPT_AUTOHELP POPT_TABLEEND }; int main(int argc, char *argv[]) { poptContext optCon = rpmioInit(argc, argv, optionsTable); ARGV_t av; int ac; const char * dn; int rc = 0; if (__debug) { _av_debug = -1; _dav_debug = -1; _ftp_debug = -1; _url_debug = -1; _rpmio_debug = -1; } av = poptGetArgs(optCon); ac = argvCount(av); if (ac < 1) { poptPrintUsage(optCon, stderr, 0); goto exit; } while (rc == 0 && (dn = *av++) != NULL) rc = printGlob(dn); exit: optCon = rpmioFini(optCon); return rc; }
int main(int argc, char *const argv[]) { poptContext optCon = rpmioInit(argc, argv, optionsTable); ARGV_t av; int ac; rpmdict dict; EVR_t evr = (EVR_t) xcalloc(1, sizeof(*evr)); const char * arg; int rc = 0; int xx; int i; if ((progname = strrchr(argv[0], '/')) != NULL) progname++; else progname = argv[0]; av = NULL; (void) argvAppend(&av, poptGetArgs(optCon)); ac = argvCount(av); if (ac == 0 || !strcmp(*av, "-")) { av = NULL; xx = argvFgets(&av, NULL); ac = argvCount(av); } dict = rpmdictCreate(); if (av != NULL) for (i = 0; (arg = av[i]) != NULL; i++) { if (*arg == '\0') /* Skip cruft */ continue; s.total++; if (nofiles && *arg == '/') { /* Skip file paths. */ s.files++; continue; } if (noKdigests && isKdigest(arg)) { /* Skip kernel MD5/SHA1. */ s.Kdigest++; continue; } if (noOdigests && isOdigest(arg)) { /* Skip OCAML EVR strings. */ s.Odigest++; continue; } /* Split E:V-R into components. */ xx = rpmEVRparse(arg, evr); if (evr->F[RPMEVR_E] == NULL) { evr->F[RPMEVR_E] = "0"; s.Emiss++; } if (evr->F[RPMEVR_R] == NULL) { evr->F[RPMEVR_R] = ""; s.Rmiss++; } rpmdictAdd(dict, evr->F[RPMEVR_E]); rpmdictAdd(dict, evr->F[RPMEVR_V]); rpmdictAdd(dict, evr->F[RPMEVR_R]); if (__debug) fprintf(stderr, "%5d: %s => %s:%s-%s\n", s.total, arg, evr->F[RPMEVR_E], evr->F[RPMEVR_V], evr->F[RPMEVR_R]); evr->str = _free(evr->str); } (void) argvSort(dict->av,(int (*)(const char **, const char **))rpmdictCmp); /* Compute size of string & uuid store. */ if (av != NULL) for (i = 0; av[i] != NULL; i++) { s.strnb += sizeof(*av) + strlen(av[i]) + 1; s.uuidnb += 64/8; } s.strnb += sizeof(*av) + 1; /* Compute size of dictionary store. */ for (i = 0; dict->av[i] != NULL; i++) { s.dictnb += sizeof(*dict->av) + strlen(dict->av[i]) + 1; } s.dictnb += sizeof(*dict->av) + 1; fprintf(stderr, "total:%u files:%u Kdigest:%u Odigest:%u Emiss:%u Rmiss:%u dictlen:%u strnb:%u dictnb:%u uuidnb:%u\n", s.total, s.files, s.Kdigest, s.Odigest, s.Emiss, s.Rmiss, argvCount(dict->av), (unsigned)s.strnb, (unsigned)s.dictnb, (unsigned)s.uuidnb); if (__debug) argvPrint("E:V-R dictionary", dict->av, NULL); evr = _free(evr); dict = rpmdictFree(dict); av = argvFree(av); optCon = rpmioFini(optCon); return rc; }