#include <stdio.h>

extern char *malloc();

void Nomem();

/*
 * allocate x bytes of far memory
 */
char *Alloc(x)
long x;
{
	char *fp;

	if (x >= 0x10000) {
		printf("Error! malloc() too big!\n");
		exit(-1);
	}
	if ((fp = malloc((short) x)) == NULL)
		Nomem();		/* memory allocation error */
	return(fp);
}

/*
 * a memory allocation request has failed
 */
void Nomem ()
{
	printf( "out of memory\n" );
	exit( -1 );
}

/*
 * Free memory alloctated by Alloc();
 */
Free(x)
char *x;
{
	free(x);
}

/* edlib  version 1.0 of 04/08/88 */
/*
    string to upper changes all lower case letters in a string to upper
    case.
*/
#include <ctype.h>

char *strupr(str)
char *str;
{
    char *temp = str;

    for ( ; *temp ; temp++ )
        *temp = (char) toupper(*temp);

    return(str);
}

int stricmp(str1,str2)
char *str1,*str2;
{
    int index = 0;

    while ( str1[index] && str2[index] &&
            tolower(str1[index]) == tolower(str2[index]) )
        ++index;

    return( (tolower(str1[index]) < tolower(str2[index])) ? -1 :
          ( (tolower(str1[index]) > tolower(str2[index])) ?  1 : 0) );
}
