completely rewritten for performance, ease of use
CVS patchset: 246 CVS date: 1996/01/30 03:46:46
This commit is contained in:
parent
a6b200db99
commit
403095d402
54
lib/var.c
54
lib/var.c
|
@ -1,51 +1,25 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "var.h"
|
||||
|
||||
static char *topdir = "/usr/src";
|
||||
static char *sourcedir = "/usr/src/SOURCES";
|
||||
static char *builddir = "/usr/src/BUILD";
|
||||
static char *specdir = "/usr/src/SPECS";
|
||||
static char *rpmdir = "/usr/src/RPMS";
|
||||
static char *srpmdir = "/usr/src/SRPMS";
|
||||
static char *docdir = "/usr/doc";
|
||||
static char *optflags = "-O2";
|
||||
static char *root = NULL;
|
||||
#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)
|
||||
{
|
||||
switch (var) {
|
||||
case RPMVAR_SOURCEDIR:
|
||||
return sourcedir;
|
||||
case RPMVAR_BUILDDIR:
|
||||
return builddir;
|
||||
case RPMVAR_DOCDIR:
|
||||
return docdir;
|
||||
case RPMVAR_TOPDIR:
|
||||
return topdir;
|
||||
case RPMVAR_SPECDIR:
|
||||
return specdir;
|
||||
case RPMVAR_OPTFLAGS:
|
||||
return optflags;
|
||||
case RPMVAR_ROOT:
|
||||
return root;
|
||||
case RPMVAR_RPMDIR:
|
||||
return rpmdir;
|
||||
case RPMVAR_SRPMDIR:
|
||||
return srpmdir;
|
||||
}
|
||||
return NULL;
|
||||
if (var > RPMVAR_LASTVAR)
|
||||
return NULL;
|
||||
else
|
||||
return values[var];
|
||||
}
|
||||
|
||||
void setVar(int var, char *val)
|
||||
{
|
||||
switch (var) {
|
||||
case RPMVAR_ROOT:
|
||||
if (root) {
|
||||
free(root);
|
||||
}
|
||||
root = strdup(val);
|
||||
break;
|
||||
/* XXX should probably have default/error checking here */
|
||||
}
|
||||
if (var > RPMVAR_LASTVAR)
|
||||
return ; /* XXX should we go harey carey here? */
|
||||
|
||||
if (values[var]) free(values[var]);
|
||||
values[var] = strdup(val);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue