aboutsummaryrefslogtreecommitdiffstats
path: root/rpmeval.c
blob: a32505313dcd425a71fdda9d95edd24fda62352f (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
31
32
/* $Id: rpmeval.c 271130 2010-10-16 11:12:45Z peroyvind $ */

#include <stdint.h>

#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)
{
    rpmRC rc;
    char *results;
    if (argc != 3) {
        fprintf(stdout, "Not enough arguments: %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;
}