aboutsummaryrefslogtreecommitdiffstats
path: root/rpmeval.c
blob: df807df9a41b670662af238b622799c61ada7e48 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/* $Id$ */

#ifdef HAVE_RPM_RPMLIB_H
#include <rpm/rpmlib.h>
#else
#include <rpm/rpmio.h>
#include <rpm/rpmtag.h>
#endif
#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;
}