/* Steven Andrews, 3/14/02.
Compares assorted items, stored as voids.
See documentation called VoidComp_doc.doc.
Copyright 2003-2007 by Steven Andrews.  This work is distributed under the terms
of the Gnu Lesser General Public License (LGPL). */

#include <string.h>
#include "VoidComp.h"

int StringCmp(void *str1,void *str2) {
	if(str1&&str2) return strcmp((char *) str1,(char *) str2);
	else if(str1) return 1;
	else if(str2) return -1;
	else return 0; }

int PointerCmp(void *ptr1,void *ptr2) {
	return (ptr1!=ptr2); }

int IntCmp(void *num1,void *num2) {
	if((int) num1<(int) num2) return -1;
	else if((int) num1>(int) num2) return 1;
	else return 0; }

int FloatCmp(void *num1,void *num2) {
	float f1,f2;
	
	f1=*((float *) num1);
	f2=*((float *) num2);
	if(f1<f2) return -1;
	else if(f1>f2) return 1;
	else return 0; }

int DoubleCmp(void *num1,void *num2) {
	double f1,f2;
	
	f1=*((double *) num1);
	f2=*((double *) num2);
	if(f1<f2) return -1;
	else if(f1>f2) return 1;
	else return 0; }
