int main(int argc, char *argv[]) { poptContext optCon = rpmioInit(argc, argv, optionsTable); const char * pythonFN = NULL; int pythonFlags = 0; rpmpython python = rpmpythonNew(pythonFN, pythonFlags); ARGV_t av = poptGetArgs(optCon); int ac = argvCount(av); const char * fn; int rc = 1; /* assume failure */ if (ac < 1) { poptPrintUsage(optCon, stderr, 0); goto exit; } while ((fn = *av++) != NULL) { const char * result; rpmRC ret; result = NULL; if ((ret = rpmpythonRunFile(python, fn, &result)) != RPMRC_OK) goto exit; if (result != NULL && *result != '\0') fprintf(stdout, "%s\n", result); } rc = 0; exit: python = rpmpythonFree(python); optCon = rpmioFini(optCon); return rc; }
int main(int argc, char *argv[]) /*@globals __assert_program_name, rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/ /*@modifies __assert_program_name, _rpmrepo, rpmGlobalMacroContext, fileSystem, internalState @*/ { poptContext optCon = rpmioInit(argc, argv, optionsTable); const char ** av = NULL; int ac; int rc = 1; /* assume failure. */ int i; /*@-observertrans -readonlytrans @*/ __progname = "rpmgpg"; /*@=observertrans =readonlytrans @*/ av = poptGetArgs(optCon); if (av == NULL || av[0] == NULL) { poptPrintUsage(optCon, stderr, 0); goto exit; } ac = argvCount(av); if (av != NULL) for (i = 0; i < ac; i++) { } rc = 0; exit: optCon = rpmioFini(optCon); return rc; }
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; }
int main(int argc, char **argv) { poptContext optCon = rpmioInit(argc, argv, optionsTable); const char ** av = NULL; int ac; int r = -1; _rpmaug_debug = -1; if (_rpmaugLoadargv != NULL) _rpmaugLoadpath = argvJoin(_rpmaugLoadargv, PATH_SEP_CHAR); _rpmaugI = rpmaugNew(_rpmaugRoot, _rpmaugLoadpath, _rpmaugFlags); if (_rpmaugI == NULL) { fprintf(stderr, "Failed to initialize Augeas\n"); goto exit; } #if defined(WITH_READLINE) readline_init(); #endif av = poptGetArgs(optCon); ac = argvCount(av); if (ac > 0) { // Accept one command from the command line const char * cmd = argvJoin(av, ' '); const char *buf; buf = NULL; r = rpmaugRun(NULL, cmd, &buf); cmd = _free(cmd); if (buf && *buf) fprintf(stdout, "%s", buf); } else { r = main_loop(); } exit: if (_rpmaugLoadargv) _rpmaugLoadpath = _free(_rpmaugLoadpath); _rpmaugLoadargv = argvFree(_rpmaugLoadargv); _rpmaugI = rpmaugFree(_rpmaugI); optCon = rpmioFini(optCon); return (r == 0 ? EXIT_SUCCESS : EXIT_FAILURE); }
int main(int argc, char *argv[]) { poptContext optCon = rpmioInit(argc, argv, optionsTable); const char * perlFN = NULL; int perlFlags = 0; rpmperl perl = rpmperlNew(perlFN, perlFlags); ARGV_t av = poptGetArgs(optCon); int ac = argvCount(av); #ifdef NOTYET const char * fn; #endif const char * result; int rc = 1; /* assume failure */ #ifdef NOTYET if (ac < 1) { poptPrintUsage(optCon, stderr, 0); goto exit; } while ((fn = *av++) != NULL) { rpmRC ret; result = NULL; if ((ret = rpmperlRunFile(perl, fn, &result)) != RPMRC_OK) goto exit; if (result != NULL && *result != '\0') fprintf(stdout, "%s\n", result); } rc = 0; #else result = NULL; if (rpmperlRun(perl, "print \"Hello, world!\n\";", &result) != RPMRC_OK) goto exit; if (result && *result) fprintf(stdout, "%s\n", result); rc = 0; #endif exit: perl = rpmperlFree(perl); optCon = rpmioFini(optCon); return rc; }
int main(int argc, char *argv[]) { poptContext optCon = rpmioInit(argc, argv, optionsTable); ARGV_t av = NULL; 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) { #ifdef DYING /* XXX davOpendir() is adding pesky trailing '/'. */ /* XXX Add pesky trailing '/' to http:// URI's */ size_t nb = strlen(dn); dn = rpmExpand(dn, (dn[nb-1] != '/' ? "/" : NULL), NULL); rc = dirWalk(dn); dn = _free(dn); #else rc = dirWalk(dn); #endif } exit: optCon = rpmioFini(optCon); return rc; }
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; }