summaryrefslogtreecommitdiff
path: root/lib/var.c
blob: ce0cadca11350a4746942f44354e33a2fff37b3e (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
#include <stdlib.h>
#include <string.h>

#include "rpmlib.h"

/* this is incredibly simple minded, but should be fine for what we need */

static char * values[RPMVAR_LASTVAR + 1];

char *getVar(int var)
{
    if (var > RPMVAR_LASTVAR) 
	return NULL;
    else 
	return values[var];
}

void setVar(int var, char *val)
{
    if (var > RPMVAR_LASTVAR) 
	return ;		/* XXX should we go harey carey here? */
   
    if (values[var]) free(values[var]);

    if (val)
	values[var] = strdup(val);
    else
	values[var] = NULL;
}