rpm
5.2.1
|
00001 #include "system.h" 00002 00003 #include <popt.h> 00004 #include <rpmio_internal.h> 00005 #include <rpmcb.h> /* XXX fnpyKey */ 00006 #include <argv.h> 00007 #include <rpmtypes.h> 00008 #include <rpmtag.h> 00009 00010 #define _RPMDS_INTERNAL 00011 #define _RPMEVR_INTERNAL 00012 #include <rpmds.h> 00013 00014 #include "debug.h" 00015 00016 const char *__progname; 00017 #define progname __progname 00018 00019 static int pointRpmEVR(ARGV_t av) 00020 { 00021 EVR_t a = memset(alloca(sizeof(*a)), 0, sizeof(*a)); 00022 EVR_t b = memset(alloca(sizeof(*b)), 0, sizeof(*b)); 00023 int rc; 00024 00025 (void) rpmEVRparse(av[0], a); 00026 (void) rpmEVRparse(av[2], b); 00027 00028 rc = rpmEVRcompare(a, b); 00029 if (rc < 0) 00030 rc = !(av[1][0] == 'l'); 00031 else if (rc > 0) 00032 rc = !(av[1][0] == 'g'); 00033 else 00034 rc = !(av[1][0] == 'e' || av[1][1] == 'e'); 00035 00036 a->str = _free(a->str); 00037 b->str = _free(b->str); 00038 return rc; 00039 } 00040 00041 static struct poptOption optionsTable[] = { 00042 { "debug", 'd', POPT_ARG_VAL, &_rpmevr_debug, -1, NULL, NULL }, 00043 POPT_AUTOALIAS 00044 POPT_AUTOHELP 00045 POPT_TABLEEND 00046 }; 00047 00048 int 00049 main(int argc, char *argv[]) 00050 { 00051 poptContext optCon; 00052 ARGV_t av; 00053 int ac; 00054 const char * arg; 00055 int ec = 0; 00056 int rc; 00057 int xx; 00058 00059 if ((progname = strrchr(argv[0], '/')) != NULL) 00060 progname++; 00061 else 00062 progname = argv[0]; 00063 00064 optCon = poptGetContext(argv[0], argc, (const char **)argv, optionsTable, 0); 00065 while ((rc = poptGetNextOpt(optCon)) > 0) 00066 ; 00067 00068 av = poptGetArgs(optCon); 00069 ac = argvCount(av); 00070 00071 if (ac == 0 || !strcmp(*av, "-")) { 00072 av = NULL; 00073 xx = argvFgets(&av, NULL); 00074 ac = argvCount(av); 00075 } 00076 00077 if (av != NULL) 00078 while ((arg = *av++) != NULL) { 00079 ARGV_t rav = NULL; 00080 int rac = 0; 00081 if (poptParseArgvString(arg, &rac, &rav) || rac != 3) { 00082 fprintf(stderr, _("skipping malformed comparison: \"%s\"\n"), arg); 00083 continue; 00084 } 00085 rc = pointRpmEVR(rav); 00086 free(rav); 00087 rav = NULL; 00088 rac = 0; 00089 } 00090 00091 optCon = poptFreeContext(optCon); 00092 00093 return ec; 00094 }