aboutsummaryrefslogtreecommitdiffstats
path: root/rpmeval.c
diff options
context:
space:
mode:
Diffstat (limited to 'rpmeval.c')
-rw-r--r--rpmeval.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/rpmeval.c b/rpmeval.c
new file mode 100644
index 0000000..c377dec
--- /dev/null
+++ b/rpmeval.c
@@ -0,0 +1,25 @@
+/* $Id$ */
+
+#include <rpm/rpmlib.h>
+#include <rpm/rpmmacro.h>
+
+int main(int argc, char **argv)
+{
+ int rc;
+ char *results;
+ if (argc != 3) {
+ fprintf(stdout, "Not enough argument: %d\n", argc);
+ return 1;
+ }
+ if (rc = rpmReadConfigFiles(NULL, NULL)) {
+ fprintf(stderr, "Cannot load configuration\n");
+ return rc;
+ }
+ if (rc = rpmLoadMacroFile(rpmGlobalMacroContext, argv[1])) {
+ fprintf(stderr, "Cannot read %s\n", argv[1]);
+ return rc;
+ }
+ results = rpmExpand(argv[2], NULL);
+ fprintf(stdout, "%s\n", results);
+ return 0;
+}