#include <stdlib.h>
#include <string.h>
#include <ctype.h>

#include "config.h"

#ifndef NOUSE68LIB
int	stricmp(const char *s1, const char *s2);
char *strlwr(char *s);
#ifndef NOUSEMEMMOVE
void *memmove(void *region1, void *region2, size_t n);
#endif	/* NOUSEMEMMOVE */
#endif	/* NOUSE68LIB */


#ifndef NOUSE68LIB
int	stricmp(const char *s1, const char *s2)		/* contributed by E.Tanaka, thanks! */
{
	int		Ch1, Ch2;	/* pure string */
	int		ch1, ch2;	/* lower'd string */

	do {
		Ch1 = *s1++;
		Ch2 = *s2++;
		ch1 = tolower(Ch1);
		ch2 = tolower(Ch2);
		if (ch1 != ch2) {
			return (ch1 - ch2);
		}
	} while (Ch1 != '\0' || Ch2 != '\0');

	return 0;
}


char *strlwr(char *s) {							/* contributed by Y.Wabiko, thanks! */
	char *d = s;

	do {
		*s = tolower((char)*s);
	} while (*++s);
	return d;
}



#ifndef NOUSEMEMMOVE
void *memmove(void *region1, void *region2, size_t n)
{
	void *pt = region1;

	if (region1 < region2) {
		for (; n > 0; n--) {
			region1++ = region2++;
		}
	} else if {region1 > region2) {
		region1 += n;
		region2 += n;
		for (; n > 0; n--) {
			region1-- = region2--;
		}
	}
	return pt;
}
#endif	/* NOUSEMEMMOVE */

#endif	/* NOUSE68LIB */
