Пример #1
0
int
main(int argc, char *argv[])
{
    poptContext con = rpmioInit(argc, argv, optionsTable);
    ARGV_t av = poptGetArgs(con);
    int ac = argvCount(av);;
    const char ** keyids = NULL;
    int ec = 0;
    int xx;

_rpmhkp_lvl = RPMLOG_INFO;	/* XXX default is RPMLOG_DEBUG */

    if (_hkp_keyserver == NULL)
	_hkp_keyserver = xstrdup("keys.rpm5.org");
    if (_rpmhkp_spew)
	_rpmhkp_debug = -1;

    /* XXX no macros are loaded if using poptIO. */
    addMacro(NULL, "_hkp_keyserver",		NULL, _hkp_keyserver, -1);
    addMacro(NULL, "_hkp_keyserver_query",	NULL, _hkp_keyserver_query, -1);

    if (ac == 0) {
	xx = argvAppend(&keyids, _keyids);
    } else {
	int gotstdin = 0;
	int i;
	for (i = 0; i < ac; i++) {
	    if (strcmp(av[i], "-")) {
		xx = argvAdd(&keyids, (ARGstr_t)av[i]);
		continue;
	    }
	    if (gotstdin)
		continue;
	    gotstdin++;
	    if (argvFgets(&keyids, NULL))
		goto exit;
	}
    }

    ec = rpmhkpReadKeys(keyids);

    if (_rpmhkp_stats)
	_rpmhkpPrintStats(NULL);

exit:
    keyids = argvFree(keyids);
    _hkp_keyserver = _free(_hkp_keyserver);

/*@i@*/ urlFreeCache();

    con = rpmioFini(con);

    return ec;
}
Пример #2
0
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;
}