#include <stdio.h>
#include "cstddef.h"

/* convert a lower case letter to upper case */
chupper(c)
    register        c;
{
    return ((c >= 'a' && c <= 'z') ? c - ('a' - 'A') : c);
}

/* convert an upper case letter to lower case */
chlower(c)
    register        c;
{
    return ((c >= 'A' && c <= 'Z') ? c - ('A' - 'a') : c);
}

/* find the minimum of two integers */
imin(i, j)
{
    return (i < j) ? i : j;
}

/* find the maximum of two integers */
imax(i, j)
{
    return (i > j) ? i : j;
}

cantopen(filename)
    char           *filename;
{
    fputs("Can't open: ", stderr);
    fputs(filename, stderr);
    exit(1);
}



/* convert an integer to a string in any base (2-36) */
char           *
itob(n, s, base)
    char           *s;
{
    register unsigned int u;
    register char  *p, *q;
    register        negative, c;

    if (n < 0 && base == -10)
    {
	negative = TRUE;
	u = -n;
    } else
    {
	negative = FALSE;
	u = n;
    }
    if (base == -10)		/* signals signed conversion */
	base = 10;
    p = q = s;
    do
    {				/* generate digits in reverse order */
	if ((*p = u % base + '0') > '9')
	    *p += ('A' - ('9' + 1));
	++p;
    } while ((u /= base) > 0);
    if (negative)
	*p++ = '-';
    *p = '\0';			/* terminate the string */
    while (q < --p)
    {				/* reverse the digits */
	c = *q;
	*q++ = *p;
	*p = c;
    }
    return s;
}


getkey()
{
    return (EOF);
}
