aboutsummaryrefslogtreecommitdiffstats
path: root/rpmeval.c
blob: c7193523b812062f86aeb2fd5321761e05ff0cdc (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
33
34
35
36
/* $Id$ */

#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]
#ifndef RPMDBI_LABEL
	    ,2
#endif
	    )) {
        fprintf(stderr, "Cannot read %s\n", argv[1]);
        return rc;
    }
    results = rpmExpand(argv[2], NULL);
    fprintf(stdout, "%s\n", results);
    return 0;
}