/**********************************************************************
 
	Copyright (C) 2003 Hirohisa MORI <joshua@nichibun.ac.jp>
 
	This program is free software; you can redistribute it 
	and/or modify it under the terms of the GLOBALBASE 
	Library General Public License (G-LGPL) as published by 

	http://www.globalbase.org/
 
	This program is distributed in the hope that it will be 
	useful, but WITHOUT ANY WARRANTY; without even the 
	implied warranty of MERCHANTABILITY or FITNESS FOR A 
	PARTICULAR PURPOSE.

**********************************************************************/



#include	"acrp.h"

int
cmp_site(L_CHAR * s1,int ip1,int p1,L_CHAR * s2,int ip2,int p2)
{
int lip;
char * s1p, * s2p;
	lip = get_localhostip();
	if ( s1 == 0 && ip1 == 0 )
		ip1 = lip;
	if ( s2 == 0 && ip2 == 0 )
		ip2 = lip;
	if ( s1 == 0 )
		s1p = 0;
	else	s1p = n_string(std_cm,s1);
	if ( s2 == 0 )
		s2p = 0;
	else	s2p = n_string(std_cm,s2);
	if ( hostcmp(s1p,getHA_v4(ip1),s2p,getHA_v4(ip2)) )
		return -1;
	if ( hostcmp(s1p,getHA_v4(ip1),0,getHA_v4(lip)) == 0 ) {
	int p;
		p = get_my_port();
		if ( p1 == 0 )
			p1 = p;
		if ( p2 == 0 )
			p2 = p;
	}
	if ( p1 == p2 )
		return 0;
	return -1;
}
