#include <stdlib.h>
#include <stdio.h>
#include "vaxconio.h"
#define true (!false)
#define false 0
getch()
{
	return tt_inkey();
}
long coreleft(void)
{
	return 4000000l;
}
strlwr(char *s)
{
	while (*s!=0) {*s = tolower(*s); s++;}
}
char *strupr(char *s)
{
	while (*s!=0) {*s = toupper(*s); s++;}
	return s;
}
unlink(char *filename)
{
	delete(filename);
}

#include <descrip.h>
int find_context;
static char wildstr[200];
static $DESCRIPTOR(str1,"");
static $DESCRIPTOR(str2,"");
static char rfile[200];
findfirst(char *wild, struct ffblk *ffblk, int zz)
{
	int st;
	char *s;
	strcpy(wildstr,wild);
	strcat(wildstr,";");
	str1.dsc$a_pointer = wildstr;  str1.dsc$w_length = strlen(wildstr);
	str2.dsc$a_pointer = &rfile[0];  str2.dsc$w_length = 132;
	st = LIB$FIND_FILE(&str1,&str2,&find_context);
	if ((st & 1) != 1) {
		st = LIB$FIND_FILE_END(&find_context);
		if ((st & 1) != 1) LIB$SIGNAL(st);
		return true;
	}
	ffblk->ff_name = &rfile[0]; rfile[str2.dsc$w_length] = 0;
	s = strchr(ffblk->ff_name,' ');
	*s = 0;
	trim_file(ffblk->ff_name);
	return false;
}
findnext(struct ffblk *ffblk)
{
	int st;
	char *s;
	st = LIB$FIND_FILE(&str1,&str2,&find_context);
	if ((st & 1) != 1) {
		st = LIB$FIND_FILE_END(&find_context);
		if ((st & 1) != 1) LIB$SIGNAL(st);
		return true;
	}
	ffblk->ff_name = &rfile[0]; rfile[str2.dsc$w_length] = 0;
	s = strchr(ffblk->ff_name,' ');
	if (s!=NULL) *s = 0;
	trim_file(ffblk->ff_name);
	return false;
}
trim_file(char *s)
{
	char *t;
	t = strchr(s,']');
	if (t!=NULL) memcpy(s,t+1,strlen(t));
	t = strchr(s,';');
	if (s!=NULL) *t = 0;
}
char *getsymbol(char *sym)
{
	static char mystr[200],*s;
	int r;
	short teklen=80;
	$DESCRIPTOR(symname,sym);
	$DESCRIPTOR(tekval,mystr);
	symname.dsc$w_length = strlen(sym);
	tekval.dsc$w_length = 80;
	r = lib$get_symbol(&symname,&tekval,&teklen,&1);
	mystr[teklen] = 0;
loop1:	s = strchr(mystr,'^');
	if (s!=NULL) {
		*(s+1) = *(s+1) - 64;
		memmove(s,s+1,strlen(s+1)+1);
		goto loop1;
	}
	return mystr;
}


                                                          
