#include <string.h>
#include "utype.h"
#include "umem.h"
#include "register.h"
#include "macros.h"
#include "maker.h"

extern char **_environ;
extern BOOL prm_ignoreenvmatch;

char *exepath=0;
char *phipath=0;
char *commandpath=0;
void ReadEnvironment(void)
{
	char **p = _environ;
	while (*p) {
		char buf[512], *q,*r;
		short name[200],value[512];
		strcpy(buf,*p++);
		q = strchr(buf,'=');
		if (!q)
			continue;
		r = q+1;
		while (*(q-1) == ' ')
			q--;
		*q = 0;
		ExpandFile(name,buf);
		ExpandFile(value,r);
		if (!strcmp(buf,"PATH")) {
			exepath = AllocateMemory(strlen(r)+1);
			strcpy(exepath,r);
		}
		if (!strcmp(buf,"PHI")) {
			phipath = AllocateMemory(strlen(r)+1);
			strcpy(phipath,r);
		}
		if (!strcmp(buf,"COMSPEC")) {
			commandpath = AllocateMemory(strlen(r)+1);
			strcpy(commandpath,r);
		}
		RegisterMacro(name,value,TRUE,!prm_ignoreenvmatch);
	}
}
		